elisp

How do I control emacs from a terminal?

左心房为你撑大大i 提交于 2019-12-06 14:27:59
问题 I'm trying to drive emacs on OSX using Dragon Naturally Speaking running inside a Windows VM. Rather than running emacs in the VM, I'd like to drive an emacs (built from the HEAD of the repository) already running on the mac side of things. So, after a hunt through the emacs lisp manual I came up with the following snippets of lisp (currently running from the scratch buffer while I work stuff out): ;; This part is run from an emacsclient -t session (defvar slave-frame last-event-frame) ;; and

“value returned is unused” warning when byte-compiling a macro

本小妞迷上赌 提交于 2019-12-06 13:54:36
Why does byte-compiling the the following produce a warning? (defmacro foomacro (shiftcode) `(defun foo (&optional arg) (interactive ,(concat shiftcode "p")) (message "arg is %i" arg)) `(defun bar (&optional arg) (interactive ,(concat shiftcode "Nenter a number: ")) (message "arg is %i" arg))) ;; provide backward compatibility for Emacs 22 (if (fboundp 'handle-shift-selection) (foomacro "^") (foomacro "")) This is the warning I get: $ emacs -Q --batch --eval '(byte-compile-file "foo.el")' In foomacro: foo.el:1:21:Warning: value returned from (concat shiftcode "p") is unused If I get rid of bar

Why is there blank space where there ought be line numbers in Emacs?

徘徊边缘 提交于 2019-12-06 13:02:32
I'm using (global-linum-mode t) to present line numbers in Emacs. This works just fine up-until I use the ctrl + up / down commands ( forward-paragraph and backward-paragraph ) to navigate a buffer, at which point some line numbers are rendered incorrectly (see attached image). This occurs only when I use said commands to skip entire segments of code, and the issue immediately disappears (the line numbers are rendered correctly, that is) if I start navigating the buffer by other means. The issue is present in both C and C++ modes (visualized), and I'm using Emacs 24.3.1 on x86-64 Fedora 19.

A quick way to repeatedly enter a variable name in Emacs?

廉价感情. 提交于 2019-12-06 12:47:15
I was just typing in this sort of code for Nth time: menu.add_item(spamspamspam, "spamspamspam"); And I'm wondering if there's a faster way to do it. I'd like a behavior similar to yasnippet's mirrors, except I don't want to create a snippet: the argument order varies from project to project and from language to language. The only thing that's constant is the variable name that needs to be repeated several times on the same line. I'd like to type in menu.add_item($,"") and with the point between the quotes, call the shortcut and start typing, and finally exit with C-e . This seems advantageous

Default regular expression for etags

时光总嘲笑我的痴心妄想 提交于 2019-12-06 12:21:58
I'd like to create additional regular expressions for use with etags, but I'd like them to be based upon what's already there (in particular, I'd like to add [ \t]* to the current set of regular expressions that etags uses). What are the default set of regular expressions that etags uses for .lisp files? etags doesn't generally use regular expressions to implement the languages that are built-in. Instead, it has custom parser code for each built-in language. That said, it seems for Lisp to look for just a few forms, that could be handled by regular expressions: It looks for "(" in the first

Swap parentheses and square brackets in Emacs Paredit

雨燕双飞 提交于 2019-12-06 08:42:43
问题 How can I define a command in paredit mode that swaps parentheses and square brackets? 回答1: The following code does what you request. You can bind swap-parens to whatever key binding you want. (defvar swap-paren-pairs '("()" "[]")) (defun swap-parens-at-points (b e) (let ((open-char (buffer-substring b (+ b 1))) (paren-pair-list (append swap-paren-pairs swap-paren-pairs))) (while paren-pair-list (if (eq (aref open-char 0) (aref (car paren-pair-list) 0)) (save-excursion (setq to-replace (cadr

Extract the second level headline

六眼飞鱼酱① 提交于 2019-12-06 08:08:24
For my global TODO list, I am showing breadcrumbs as suggested here : (concat \"[ \"(org-format-outline-path (org-get-outline-path)) \" ]\") ") to produce following: I would like to show only the second level of project breadcrumb. So in this case, I would only display [Project A] . I think if I can make a function that can extract the second level, I just need to prepend with %? so that [Tasks] does not appear for Tasks, but only project names would appear for Projects. What would be an ideal way of extracting the second level? All you have to do to get the second element of (org-get-outline

Mirroring location in file in two opened buffers side by side

时光怂恿深爱的人放手 提交于 2019-12-06 07:42:10
I am trying to find a package/function in emacs where it would have both files opened side by side to be at same line location mirroring the movement of whichever buffer is moving. Meaning, for two buffers opened side by side, moving in one of the buffers (page up/down, moving cursor.,..etc) would have the same movements in the other buffer. More specifically, when opening a buffer (and while activating this mode) the opened buffer should already be at the line position of the one that is already opened in the other buffer window. You could try scroll-all-mode . This switches on parallel

Emacs: Tab completion of file name appends an extra i:\cygwin

China☆狼群 提交于 2019-12-06 06:25:09
问题 I am facing some strange behavior with file-name completion in emacs. C-x C-f to find file opens up the minibuffer with i:/cygwin/home/rrajagop/StockScreener/working_copy/master_repo/stock_screener/. Hitting a TAB makes it i:/cygwini:/cygwin/home/rrajagop/StockScreener/working_copy/master_repo/stock_screener/. A couple of interesting things I've noticed: When the minibuffer opens up, i:/cygwin is greyed out and the path seems to start from /home. A C-a (go to begining of line) takes me to

Run commands in Emacs asynchronously, but display output incrementally

故事扮演 提交于 2019-12-06 05:54:18
问题 I have a utility function: (defun execute-in-buffer (command-with-args buffer) "Execute a string COMMAND-WITH-ARGS representing a shell command with arguments, inserting the results in BUFFER." (switch-to-buffer buffer) (insert (format ">>> %s\n" command-with-args)) (let* ((command-args-list (s-split " " command-with-args)) (command (car command-args-list)) (args (cdr command-args-list))) (apply 'call-process command nil buffer t args))) This allows me to do things like (execute-in-buffer "ls