elisp

Filtering text through a shell command in Emacs

别说谁变了你拦得住时间么 提交于 2019-11-28 15:46:37
In vi[m] there is the ! command which lets me pipe text through a shell command -- like sort or indent -- and get the filtered text back into the buffer. Is there an equivalent in emacs? You can select a region and type `C-u M-| command RET', and it replaces the region with the command output in the same buffer due to the interactive prefix argument of shell-command-on-region. I wrote this a few years back, it might help you: (defun generalized-shell-command (command arg) "Unifies `shell-command' and `shell-command-on-region'. If no region is selected, run a shell command just like M-x shell

Close all buffers besides the current one in Emacs

我怕爱的太早我们不能终老 提交于 2019-11-28 15:31:32
问题 How do I close all but the current buffer in Emacs? Similar to "Close other tabs" feature in modern web browsers? 回答1: For a more manual approach, you can list all buffers with C-x C-b , mark buffers in the list for deletion with d , and then use x to remove them. I also recommend replacing list-buffers with the more advanced ibuffer: (global-set-key (kbd "C-x C-b") 'ibuffer) . The above will work with ibuffer, but you could also do this: m (mark the buffer you want to keep) t (toggle marks)

Why am I getting “The authenticated user has not installed the app with client id” error when using the Google Drive API natively?

老子叫甜甜 提交于 2019-11-28 11:01:39
I'm working on a Google Drive interface for Emacs. The concept is that Emacs could provide a platform-agnostic way to load, modify and save text documents stored in Google Drive. I've registered my app and can authenticate with OAuth2 and get a file listing with the Docs List API, but when I try to execute an Insert with the Google Drive API, I see an error: "The authenticated user has not installed the app with client id ..." Reading further, it seems I need to publish my Emacs application in the Chrome Web Store to get access to the Drive API. That doesn't make sense to me...I noticed that

Maximize Emacs on start up? (not the fullscreen)

故事扮演 提交于 2019-11-28 10:46:01
It's common for me to press alt-f10 (in GNU/Linux) after Emacs start up for maximizing window (in the Emacs terminology, it's actually a frame). Most of the time I press thrice because I was too early to press first alt-f10 which makes some garbage appear around the minibuffer (Emacs display bug?) How can I automate this one? (Maybe with Gnome settings or with elisp?) I am using emacs24 (from bzr repo). Note that it's not the regular fullscreen I want which you would get by pressing f11. (defun fullscreen (&optional f) (interactive) (x-send-client-message nil 0 nil "_NET_WM_STATE" 32 '(2 "_NET

lisp filter out results from list not matching predicate

↘锁芯ラ 提交于 2019-11-28 10:40:13
I am trying to learn lisp, using emacs dialect and I have a question. let us say list has some members, for which predicate evaluates to false. how do I create a new list without those members? something like { A in L: p(A) is true } . in python there is filter function, is there something equivalent in lisp? if not, how do I do it? Thanks rootzlevel These functions are in the CL package, you will need to (require 'cl) to use them: (remove-if-not #'evenp '(1 2 3 4 5)) This will return a new list with all even numbers from the argument. Also look up delete-if-not , which does the same, but

Match regular expression as keyword in define-generic-mode

牧云@^-^@ 提交于 2019-11-28 10:30:29
I'm trying to write a new mode for emacs, using define-generic-mode. I've found a few tutorials which show how you can add keywords (as strings) which will then be highlighted. Is it possible to give define-generic-mode a regular expression so that it can then highlight anything that matches that as a keyword? I'd like to have a mode in which anything matching a date in the form 15/01/09 is displayed in a different font (preferably underlined, but I'll accept a different colour). Any ideas? Robin Here's an example of define-generic-mode which sets up the regexp to have all the dates fontified

Elisp: Conditionally change keybinding

China☆狼群 提交于 2019-11-28 10:18:06
I'm trying to write a custom tab completion implementation which tries a bunch of different completions depending on where the point is. However, if none of the conditions for completions are met I would like tab to do what ever the current mode originally intended it to do. Something like this: (defun my-custom-tab-completion () (interactive) (cond (some-condition (do-something)) (some-other-condition (do-something-else)) (t (do-whatever-tab-is-supposed-to-do-in-the-current-mode))) ;; How do I do this? Currently I'm checking for specific modes and doing the right thing for that mode, but I

Unset key binding in emacs

时光怂恿深爱的人放手 提交于 2019-11-28 09:39:47
For example, in the codes of zen-coding, the "C-j" shadows the normal behavior of "C-j" ( newline-and-indent ) (define-key zencoding-mode-keymap (kbd "C-j") 'zencoding-expand-line) Then how can I unset this keybinding and use C-j for newline-and-indent again? I tried this, but it doesn't work: (add-hook 'html-mode-hook (lambda () (progn (zencoding-mode) (local-set-key (kbd "C-j") 'newline-and-indent)))) Does anyone have ideas about this? The general way to unbind a key (for any keymap) is to define a binding of nil : (define-key KEYMAP KEY nil) For convenience, there are also two standard

How to write a key bindings in emacs for easy repeat?

核能气质少年 提交于 2019-11-28 09:15:48
Let's say I bind the key to a certain function as follows: (global-set-key (kbd "C-c =") 'function-foo) Now, I want the key binding to work as: After I press C-c = for the first time, if I want to repeat the function-foo, I don't need to press C-c again, but simply repeat pressing = . Then, after I call the function-foo for enough times, I can just press keys other than = (or explicitly press C-g ) to quit. How to do this? This may be the thing you are looking for: (defun function-foo () (interactive) (do-your-thing) (set-temporary-overlay-map (let ((map (make-sparse-keymap))) (define-key map

Passing arguments to elisp script. Again

久未见 提交于 2019-11-28 09:03:47
问题 How can I pass arguments -q -d -Q -t -L -fg -bg --color etc? Doing something like emacs --script -Q <scriptname> <arguments> definetely will not pass arguments, which are used in emacs. So how to do it? 回答1: Based on your comment on Rafael Ibraim's answer, I'm adding this second answer, as I think my first answer is also mis-interpreting your question (and if so, you may wish to edit the question to provide clarification). You can prevent Emacs from processing command line arguments using the