elisp

how to specify a property value of a variable in emacs lisp

和自甴很熟 提交于 2019-12-06 02:26:25
I use the following code in .emacs file to set default publish behavior. I put the org base directory in difference locations for difference computers: ;; define machine specific directories storing my org files (cond ((system-name-is-home) (setq org-dir "/data/org")) ((system-name-is-work) (setq org-dir "~/org"))) Thus I'd like to use a variable to specify :base-directory to org-dir instead of hard-coding it as "~/org" . How can I do that? (require 'org-publish) (setq org-publish-project-alist '( ("org-notes" :base-directory "~/org" :base-extension "org" :publishing-directory "~/tmp/"

Best way to add per-line information visually in emacs?

老子叫甜甜 提交于 2019-12-06 02:25:17
I'm writing a minor mode for emacs which, at the very least, will calculate a numeric value for each line in a buffer. I want to display this visually, preferable neatly before each line. I know some minor modes draw to the fringe, and I know overlays are an option too (are these related?), but I can't find a good example of what I want anywhere. Basically, I want to have something like the line numbers from linum-mode, but they will need to change every time the buffer is modified (actually, only whenever the line they're on changes). Something like a character counter for each line would be

Waiting for comint-mode buffer

感情迁移 提交于 2019-12-06 00:31:36
I'm trying to open a background buffer with a comint erlang-shell, and once it's up, run a call a function in emacs (using distel to send it's binaries to the erlang node). ie: ... (let ((args (append (list "-sname" node-name "-pa") path))) (get-buffer-create buffer-name) (apply #'make-comint-in-buffer node-name buffer-name "erl" nil args) (erl-check-backend (make-node-name node-name)) ... The problem is that when I call distel, the node is not yet up (epmd has no registered names) so it fails. I'm guessing this is because the inferior process has not had the chance to run yet. Is there any

“wrong-type-argument” on an Emacs function I've written

℡╲_俬逩灬. 提交于 2019-12-06 00:17:29
I'd like my tab key to do the following: If I'm in the minibuffer, use word completion. Otherwise, if a region is selected, indent it. Otherwise, indent the line at the point (using tab-to-tab-stop). Here's the code, some of which is based on fragments I've found elsewhere on the Internet: (defun my-tab () "If region is selected, indent it and keep it selected, else indent current line." (interactive) (if (use-region-p) (increase-left-margin (region-beginning) (region-end) nil) (tab-to-tab-stop)) (setq deactivate-mark nil)) (defun my-untab () "If region is selected, unindent it and keep it

emacs multi-keystroke binding [duplicate]

北战南征 提交于 2019-12-06 00:07:26
This question already has an answer here: How to write a key bindings in emacs for easy repeat? 5 answers I'm still very new to EMACS, but are getting familiar when i'm going through the emacs and elisp manual. But right now i'm stuck on this: Is there a simple way to bind input sequences in regexp style? eg: the default binding for function enlarge-window-horizontally is "C-x {", is it possible to rebind it to something like "C-x ({)+" so that enlarge-window-horizontally can be called repeatedly by repeating "{" character, instead of release Ctrl key multiple times? There is another way to

Converting number to base-2 (binary) string representation [duplicate]

人盡茶涼 提交于 2019-12-05 22:32:07
This question already has an answer here: How to display numbers in different bases under elisp? 1 answer I'd like to convert a number to a binary string, e.g. (to-binary 11) -> "1011". I already found a method to convert to hex and oct: (format "%x" 11) -> "B" (format "%o" 11) -> "13" but there is apparently no format string for binary ("%b" gives an error). The conversion is simple the other way round: (string-to-number "1011" 2) -> 11 Is there any other library function to do that? While I agree this is a duplicate of the functionality, if you're asking how to do bit-twiddling in Emacs lisp

Beginning and end of the string in Emacs regexps

六月ゝ 毕业季﹏ 提交于 2019-12-05 21:57:04
What is the characters that indicate the beginning and the end of the string with newlines in it? I'm writing a trim function: (defun trim (str) (if (string-match "^[[:space:]]*\\(.+?\\)[[:space:]]*$" str) (match-string 1 str) str)) But with a string like "first/nnext" (got from shell-command-to-string ) it returns only the "first". Reference manual says: When matching a string instead of a buffer, ‘^’ matches at the beginning of the string or after a newline character. \\' and the left one are for beginning/end of a buffer, so it simply returns nothing from a string. Therefore, how to

Why does re-search-backward give different result in python-mode?

若如初见. 提交于 2019-12-05 21:54:44
I have been using python-mode for a long time. And I always use subword-mode. But subword-mode behave strangely in python-mode. For example, the M-b movement. If there is a variable named test_varialbe and I put the cursor at the end of this variable, in python-mode M-b will make the cursor point to t while in other modes it will go to v . So I looked into the source of subword-mode and found the following function: (defun subword-backward-internal () (if (save-excursion (let ((case-fold-search nil)) (re-search-backward (concat "\\(\\(\\W\\|[[:lower:][:digit:]]\\)\\([[:upper:]]+\\W*\\)" "\\|\

How to go back to previously defined function in Emacs Lisp?

旧街凉风 提交于 2019-12-05 21:18:37
I have a function: (defun function-name (&optional args) ... <unknown content>) I redefine it with (defun function-name (&optional args) ... my own content) Can I somehow after some time remove my own version of function-name and stay with the first one? No, you cannot . Save/Restore You can save the definition yourself before redefining the function: Common Lisp : (defparameter *old-def* (fdefinition 'function-name)) (defun function-name ...) ... (setf (fdefinition 'function-name) *old-def*) Emacs Lisp : (defconst *old-def* (symbol-function 'function-name)) (defun function-name ...) ... (fset

Is there a apply-function-to-region-lines in emacs?

ぃ、小莉子 提交于 2019-12-05 21:02:48
问题 A lot of my work involves searching and deleting unnecessary lines of code. So I create a macro, and then select all lines (C-x h) and then run the command (apply-macro-to-region-lines) . I managed to save that command and placed it in my .emacs file; I called it cut_it_now . But now my function is not a macro anymore, so I can't use the (apply-macro-to-region-lines) function anymore. Do you know if there is (apply-function-to-region-lines) implemented somewhere? Many thanks, D 回答1: I agree