elisp

How to test `font-lock-keywords` values for Emacs Lisp code

怎甘沉沦 提交于 2020-01-01 14:44:52
问题 I pose the question because I think both the question and possible answers might help Emacs users who write Lisp code that defines font-lock-keywords . I'm providing one answer that I think helps. I'm also interested in other answers. That variable's value is a list of expressions, each of which can specify one or more patterns to match or functions to perform matching, and one or more faces for highlighting the matching text. The possibilities for font-lock-keywords values are numerous and

How to generate dynamic “Reply-To:” based on “Message-ID:”? [+detail]

这一生的挚爱 提交于 2020-01-01 08:53:26
问题 How can you generate a dynamic "Reply-To:" (and "From:") header in emacs/gnus based on Message-ID of the created message ? I would like to use external (perl) script to generate a dynamic +detail part based on the "Messaged-ID:" header. user+detail@example.net I have managed to create a header with content generated by my external script. The script gets usenet group name as command line parameter. I would like to pass it the message-id value too. My current code ~/.emacs : '(gnus-posting

Elisp split-string function to split a string by . character

﹥>﹥吖頭↗ 提交于 2020-01-01 07:36:08
问题 I am trying to split a string using 'split-string' function based on the . character. But (split-string "1.2.3" ".") doesn't work at all. It just returns a list of variable number of empty strings. Is . a special character that needs to be escaped or specified in some different way? 回答1: Here is the official documentation for split-string function - http://www.gnu.org/software/emacs/manual/html_mono/elisp.html#Creating-Strings. The second argument to the split-string function in (split-string

How to “URL decode” a string in Emacs Lisp?

落爺英雄遲暮 提交于 2020-01-01 07:30:14
问题 I've got a string like "foo%20bar" and I want "foo bar" out of it. I know there's got to be a built-in function to decode a URL-encoded string (query string) in Emacs Lisp, but for the life of me I can't find it today, either in my lisp/ folder or with google. Anybody remember what it's called? 回答1: org-link-unescape does the job for very simple cases ... w3m-url-decode-string is better, but it isn't built in and the version I have locally isn't working with Emacs 23. 回答2: url-unhex-string

Evaluate emacs lisp expression on command line

孤街醉人 提交于 2020-01-01 05:08:17
问题 I'm a newbie to emacs. I'm working with emacs-24.1 on redhat linux, and trying to evaluate an elisp expression. What I want emacs to do is to evaluate the elisp expression without launching emacs itself. I'm trying different things emacs --eval '(+ 2 3)' I do not know if emacs is evaluating the expression, but the result is not shown on console and emacs window comes up. Next I tried this emacsclient --eval '(+ 2 3)' Emacs client is expecting a server. It could not find the server and hence

Difference between symbol and variable name in emacs lisp

雨燕双飞 提交于 2019-12-31 10:45:30
问题 I'm wondering what the difference is between (add-to-list 'flymake-allowed-file-name-masks '("\\.py\\'" flymake-pylint-init)) and (add-to-list flymake-allowed-file-name-masks '("\\.py\\'" flymake-pylint-init)) What is the clear meaning of the apostrophe here? 回答1: The apostrophe is a quote, which tells the interpreter to not parse the following expression (the symbol name). Thus, 'add-to-list gets the symbol which contains the list value that is intended to be evaluated. To learn more about

Elisp mechanism for converting PCRE regexps to emacs regexps

ⅰ亾dé卋堺 提交于 2019-12-31 08:59:09
问题 I admit significant bias toward liking PCRE regexps much better than emacs, if no no other reason that when I type a '(' I pretty much always want a grouping operator. And, of course, \w and similar are SO much more convenient than the other equivalents. But it would be crazy to expect to change the internals of emacs, of course. But it should be possible to convert from a PCRE experssion to an emacs expression, I'd think, and do all the needed conversions so I can write: (defun my-super

How to sum a list of numbers in Emacs Lisp?

天涯浪子 提交于 2019-12-31 08:45:13
问题 This works: (+ 1 2 3) 6 This doesn't work: (+ '(1 2 3)) This works if ' cl-* ' is loaded: (reduce '+ '(1 2 3)) 6 If reduce were always available I could write: (defun sum (L) (reduce '+ L)) (sum '(1 2 3)) 6 What is the best practice for defining functions such as sum ? 回答1: (apply '+ '(1 2 3)) 回答2: If you manipulate lists and write functional code in Emacs, install dash.el library. Then you could use its -sum function: (-sum '(1 2 3 4 5)) ; => 15 回答3: Linearly recursive function (sum L) ;; ;;

Useful keyboard shortcuts and tips for ESS/R

自古美人都是妖i 提交于 2019-12-31 07:58:27
问题 I would like to ask regular ESS/R users what key bindings do they use frequently and tips on using ESS/R. 回答1: I have set several shortcuts in my .emacs file. The most useful are: C-tab to switch between the R command line and the file (similar to josh answer, but much faster): (global-set-key [C-tab] 'other-window) Control and up/down arrow keys to search history with matching what you've already typed: (define-key comint-mode-map [C-up] 'comint-previous-matching-input-from-input) (define

Useful keyboard shortcuts and tips for ESS/R

别等时光非礼了梦想. 提交于 2019-12-31 07:58:26
问题 I would like to ask regular ESS/R users what key bindings do they use frequently and tips on using ESS/R. 回答1: I have set several shortcuts in my .emacs file. The most useful are: C-tab to switch between the R command line and the file (similar to josh answer, but much faster): (global-set-key [C-tab] 'other-window) Control and up/down arrow keys to search history with matching what you've already typed: (define-key comint-mode-map [C-up] 'comint-previous-matching-input-from-input) (define