elisp

Setting auto-mode-alist in emacs

大城市里の小女人 提交于 2019-11-30 04:35:43
I notice that the current auto-mode-alist entries all end with a single quote, for example ("\\.java\\'" . java-mode) What is the purpose of the single quote. I would have expected to see ("\\.java$" . java-mode) The reason I ask is that I am trying to get files with names matching regexp ^twiki\.corp.* to open in org-mode. I have tried the following without success: (add-to-list 'auto-mode-alist '("^twiki\\.corp" . org-mode)) (add-to-list 'auto-mode-alist '("\\'twiki\\.corp" . org-mode)) The following works: (add-to-list 'auto-mode-alist '("twiki\\.corp" . org-mode)) but is not quite what I

how to align arguments to functions in emacs?

我们两清 提交于 2019-11-30 04:13:47
Say if I have the following: func(arg1, arg2, arg3...) func(longargarg1, longerarg2, arg3,...) ... How do I align the arguments so that it's like following? func(arg1 , arg2 , arg3...) func(longargarg1, longerarg2, arg3,...) ... [I can use M-x align-regex to align the first argument, but I cannot cook up with a suitable regex to align the rest of the arguments. Bonus point if the answer also take cares of the case when some arguments are strings with commas in them.] Select the region, then: C-u M-x align-regexp RET ,\(\s-*\) RET RET RET y The regexp says to align commas with spaces following

Unicode characters in emacs term-mode

大城市里の小女人 提交于 2019-11-30 03:58:48
I use ansi-term for my normal terminal sessions. I tend to use unicode characters in my prompt to do things like set the trailing character based on the type of source control I'm using. I use the character "±" as my prompt for git repositories. In Emacs' ansi-term, my prompt isn't rendered as unicode, and shows as "\302\261". Displaying the current coding system shows that it defaults to utf-8-unix for input to the process, but I get raw binary as the decoding output. I can hit C-c RET p to change the encoding and decoding coding systems. I'm drawing a blank as to how to set this

Make emacs next-buffer skip *Messages* buffer

跟風遠走 提交于 2019-11-30 03:37:20
问题 I'd like to make a simple change to Emacs so that the next-buffer and previous-buffer commands (which I have bound to C-x <RIGHT> and C-x <LEFT> will skip over the *Messages* buffer. I'm using Emacs 24 and the Emacs Starter Kit. I've read the following related questions and answers, but they are not what I want: Buffer cycling in Emacs: avoiding scratch and Messages buffer Emacs disable *Messages* buffer Emacs Lisp Buffer out of focus function? Here are some of the reasons why they don't work

How to periodically run a task within emacs?

假装没事ソ 提交于 2019-11-30 02:52:48
Is there a way to periodically run an elisp function in a long-running emacs, similar to cron, but within the emacs process? For example I want to "automatically run (recentf-save-list) every half hour" because it otherwise only runs on exit, which sucks when emacs occasionally crashes. (There are other examples as well so looking for a general solution rather than one in particular for recentf). Check out run-with-timer . (run-with-timer 0 (* 30 60) 'recentf-save-list) You might also find midnight mode useful. One can arbitrarily define 'midnight' and then add hooks as desired. 来源: https:/

Assign IDs to every entry in Org-mode

为君一笑 提交于 2019-11-30 02:28:13
Org-mode has a bundled extension called org-id , that implements global unique IDs for org-mode files. Every entry (a headline with its body) can have an ID property in its :PROPERTIES: drawer. New ID for a single entry can be assigned with a function org-id-get-create . How can I assign an ID to every entry in an org-mode file? I could use an Emacs method of automating this, like a macro that calls org-id-get-create for every string starting with * . But I'd like to know if org-mode already has that capability. If not, please recommend the most idiomatic way to write an elisp code for this

Is there an Emacs Lisp library for generating HTML?

人走茶凉 提交于 2019-11-30 00:22:44
I'm looking for a solution that allows me to write native Emacs Lisp code and at compile time turns it into HTML, like Franz's htmlgen : (html ((:div class "post") (:h1 "Title") (:p "Hello, World!"))) Of course I can write my own macros , but I'm interested if there are any projects around this problem. Trey Jackson As you found out , xmlgen generates XML from a list structure. What I did find disappointing with the ``xmlgen` package that the format it supports is not quite the inverse of Emacs' xml parser . I did add this to my copy of xmlgen: ;; this creates a routine to be the inverse of

Emacs — How to replace nth element of a list with a let-bound variable

夙愿已清 提交于 2019-11-29 23:44:58
问题 I have not found any examples of how to replace the nth element of a list without first adding every element ( one-by-one ) with the function add-to-ordered-list -- e.g., (add-to-ordered-list 'the-list 'a 1) . That requires subsequently deleting the element -- e.g., (delq a the-list) . The third step in the process is to add the new element -- e.g., (add-to-ordered-list 'the-list "HELLO-WORLD!" 1) . As the following function named variable-list-example uses 26 elements, I'm looking for a

Emacs: adding 1 to every number made of 2 digits inside a marked region

二次信任 提交于 2019-11-29 23:01:31
Imagine I've got the following in a text file opened under Emacs: some 34 word 30 another 38 thing 59 to 39 say 10 here 47 and I want to turn into this, adding 1 to every number made of 2 digits: some 35 word 31 another 39 thing 60 to 40 say 11 here 48 (this is a short example, my actual need is on a much bigger list, not my call) How can I do this from Emacs? I don't mind calling some external Perl/sed/whatever magic as long as the call is made directly from Emacs and operates only on the marked region I want. How would you automate this from Emacs? I think the answer I'm thinking of consist

Emacs: 'Find file' without changing working directory

微笑、不失礼 提交于 2019-11-29 22:41:32
问题 My c/c++ projects tend to have fairly straightforward directory structures which separate out src, include, bin, etc. I also tend to have a master makefile in the uppermost directory. When working like this in Emacs, I always have to issue M-x cd uppermost-dir in order for my compilation shortcuts to work as expected. Is there a way to keep the current directory the same as the one from which I launch Emacs? That is, can I stop Emacs from changing it's working directory when I open a file?