elisp

Emacs Lisp: How to use interactive (for conditional arguments)?

泪湿孤枕 提交于 2019-12-01 08:08:15
I want to ask a second question to the user depending on the answer to the first one. (defun something (a b) (interactive (list (read-number "First num: ") (read-number "Second num: "))) (message "a is %s and b is %s" a b)) So I need a way to test the entry values : (defun something-else (a &optional b) (interactive (list (read-number "First num: ") (if (< a 2) (read-number "Second num: ")))) (message "a is %s" a)) But if: Symbol's value as variable is void: a Question : How can I use interactive in a really interactive way? (defun xtest (a &optional b) (interactive (let (a b) (setq a (read

Emacs tab between buffers

别说谁变了你拦得住时间么 提交于 2019-12-01 07:57:43
问题 Is there a way to switch between buffers without having to go through the buffer-list, or writing the name of the buffer that I want to switch to? More specific I wonder if emacs can tab between buffers much like how it is working in notepad++ 回答1: Emacs 22.1 and higher supports the previous-buffer ( C-x <left arrow> ) and next-buffer ( C-x <right arrow> ) commands. These two commands can be added to older Emacsen using this script. 回答2: I've never ended up using C-x <right> or C-x <C-right>

How to add a tool-bar button in emacs?

别来无恙 提交于 2019-12-01 07:54:36
问题 I try to add a button in the tool-bar but that doesn't works. how to do that, i check in Emacs wiki and i find nothing. I used emacs 24.3.1. The toolsbar are displayed but not my new item. I can run it with eval-buffer but not with my .emacs or find another solution to resolve that. When i add it with eval-buffer my button leave my toolbar after a scroll. (defun omar-hotel () "another nonce menu function" (interactive) (message "hotel, motel, holiday inn")) (define-key global-map [tool-bar

How to set emacsclient background as Emacs background?

百般思念 提交于 2019-12-01 07:15:45
问题 I've got (in my .emacs) (set-background-color "#101416") (set-foreground-color "#f6f3e8") And I've got 2 bindings: alias ex='emacsclient -nw' alias ec='emacsclient -c -a ""' ex works fine to open client in terminal but when I want to open it as a frame I've got white background :( Why and how can I use my dark background there? 回答1: set-background-color and set-foreground-color only affect the current frame, and your .emacs file is not executed when running emacsclient . Try setting the

How does emacs url package handle authentication?

让人想犯罪 __ 提交于 2019-12-01 07:15:20
I have not seen a really good example on the web. How can I add authentication to a request like this: (defun login-show-posts () (interactive) (let ((url-request-method "GET") (url-request-extra-headers '(("Content-Type" . "application/xml")))) (url-retrieve "http://localhost:3000/essay/1.xml" (lambda (status) (switch-to-buffer (current-buffer)) )))) if for example, the user and pass is admin:admin? I got the impression that url.el was designed mostly for interactive operations, i.e. you do a call without authorisation, the server responds with a 403 "authorization needed" (correct code?)

How to use hl-line-mode to highlight just one (1) line when visual-line-mode is enabled

半世苍凉 提交于 2019-12-01 07:09:30
问题 Does anyone have an alternative to, or a modification of, hl-line-mode so that just one (1) horizontal line will be highlighted when visual-line-mode is enabled? Presently, the entire word-wrapped line gets highlighted, even though it may span several horizontal lines. I'm using a fairly recent version of Emacs Trunk. 回答1: You should be able to control this using hl-line-range-function , giving it code that stops at the position used by end-of-visual-line . (100% untested -- just checked the

Emacs region highlighting

て烟熏妆下的殇ゞ 提交于 2019-12-01 06:52:17
Is there a way to highlight a string in a text (but not ALL such strings) in a buffer where font-lock-mode is on. Let's imagine I have a buffer with SQL mode and I want to highlight a string in it. The following code does not work (set-text-properties 10 20 '(face hi-yellow)) When I call (font-lock-mode -1) it works, but all sql highlighting disappears. There must be a solution because it's possible to select a region and it will be highlighted but I can't figure out how to do it programmatically Have a look at http://www.emacswiki.org/emacs/HighlightTemporarily . Both MarkerPens and Highlight

How to pass a lambda expression in Elisp

喜你入骨 提交于 2019-12-01 06:48:49
So, I'm trying to make a generic web search function in Elisp: (defun look-up-base (url-formatter) (let (search url) (setq search(thing-at-point 'symbol)) (setq url (url-formatter search)) (browse-url url)) ) This function will just grab the word under the cursor, format the word for web search using url-formatter and then open up the search string in the web browser to perform the search. Next, I try to implement a function which will Google the word under the cursor, using the previous function as a basis. (defun google () (interactive) (look-up-base (lambda (search) (concat "http://www

How to pass a lambda expression in Elisp

北城以北 提交于 2019-12-01 05:24:00
问题 So, I'm trying to make a generic web search function in Elisp: (defun look-up-base (url-formatter) (let (search url) (setq search(thing-at-point 'symbol)) (setq url (url-formatter search)) (browse-url url)) ) This function will just grab the word under the cursor, format the word for web search using url-formatter and then open up the search string in the web browser to perform the search. Next, I try to implement a function which will Google the word under the cursor, using the previous

How to redefine a key inside a “minibuffer” mode-map?

浪子不回头ぞ 提交于 2019-12-01 04:57:34
I'm trying to redefine the keys used to navigate the history when inside several commands accepting regexps and offering C-p / C-n history navigation. I'd like to use other keys, in addition to C-p / C-n. For example when using occur or replace-regexp , C-p and C-n can be used to go to previous and next elements. I've tried several things but can't make it work. I think I'm missing the "big picture" here. Which mode-map do I need to modify, when and how? Everything I tried failed. P.S: Note that I've got my own minor mode with all my keymaps as adviced here. I'm assuming you just needed