elisp

Define an emacs command that calls another emacs command (preserving interactive stuff)

一世执手 提交于 2019-12-04 15:28:47
How can I define an emacs command X that does something and then calls another emacs command Y and also copying the interactive interface of the command Y too? I want to define an altenative version of query-replace with temporarilly toggled value of case-fold-search: (defun alt-query-replace (a b c d e) (interactive) (let ((case-fold-search (not case-fold-search)) (query-replace a b c d e))) This doesn't work. When I call alt-query-replace, it says "wrong number of arguments". I want the interactive interface of alt-query-replace to be the same as query-replace. Do I need to inspect the

A smarter alternative to delete-window?

冷暖自知 提交于 2019-12-04 15:01:31
Sometimes I get multiple windows open for the same buffer (or a similar one) and I have to differentiate whether or not the buffer in the window is the same as another before deciding to either kill it or delete the window. Is there a way in emacs to simply delete a window only if the buffer exists already in another? Ideally I would like the same function to also kill the buffer and the window if it is the only instance of the buffer in a window. (defun delete-extra-windows () (interactive) (let* ((selwin (selected-window)) (buf (window-buffer selwin))) (walk-windows (lambda (ww) (unless (eq

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

血红的双手。 提交于 2019-12-04 14:53:51
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 /home and not to i:/cygwin. So it looks like something in emacs is parsing the path to start from /home

Swap parentheses and square brackets in Emacs Paredit

不羁的心 提交于 2019-12-04 13:58:52
How can I define a command in paredit mode that swaps parentheses and square brackets? 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 paren-pair-list)) (goto-char b) (delete-char 1) (insert (aref to-replace 0)) (goto-char (- e 1)) (delete

Create a new mode in Emacs

懵懂的女人 提交于 2019-12-04 13:03:55
I know nothing about Emacs Lisp (or any Lisp, for that matter). I want to do something that seems very simple, yet I have had no luck with online guides. I want to create "packet-mode.el" for .packet files. I want to do the following: Enable C++ mode Make packet a keyword, while leaving the rest of C++ mode unchanged (define-derived-mode packet-mode fundamental-mode (font-lock-add-keywords 'c++-mode `(("packet" . font-lock-keyword-face))) (c++-mode)) (add-to-list 'auto-mode-alist '("\\.packet\\'" . packet-mode) (provide 'packet-mode) I've also tried switching the order of the statements in

Emacs complaining with invalid function?

不打扰是莪最后的温柔 提交于 2019-12-04 12:47:53
When I press C-c c with the following code on a buffer, Emacs complains with Invalid function: (select-current-line) . Why? (defun select-current-line () "Select the current line" (interactive) (end-of-line) ; move to end of line (set-mark (line-beginning-position))) (defun my-isend () (interactive) (if (and transient-mark-mode mark-active) (isend-send) ((select-current-line) (isend-send))) ) (global-set-key (kbd "C-c c") 'my-isend) Not that it matters, but for those interested isend-send is defined here. You are missing a progn form to group statements together: (defun my-isend ()

In Emacs, how do I figure out which package is loading tramp?

时光毁灭记忆、已成空白 提交于 2019-12-04 12:25:01
问题 I have a strange interaction with tramp and cygwin-mount (I think: Emacs: Tab completion of file name appends an extra i:\cygwin). Because of this, I want to disable tramp. I'm unable to find anything in my .emacs which is loading tramp explicitly. I can see "Loading tramp..." when I hit a tab in the find-file minibuffer. I'd like to figure out what package is causing the loading of tramp and disable that. How do I go about doing this? I tried searching for (require 'tramp) but couldn't find

Creating a new buffer with text using EmacsClient

安稳与你 提交于 2019-12-04 11:34:49
问题 I have a program that can send text to any other program for further analysis (eg sed, grep, etc). I would like it to send the data to Emacs and do analysis there. How would I do that? EmacsClient takes a filename by default, this is a data string not a file and I really don't want to create and delete files just to send data to Emacs. EmacsClient has an "eval" command-line option that let's you execute lisp code instead of open files. Is there a simple lisp function that will open a new

After 'emacs --deamon' I can not see new theme in emacsclient frame. It works from 'emacs M-x server-start'

心已入冬 提交于 2019-12-04 10:19:12
问题 Minimal config https://www.refheap.com/18816 Scenario 1. Run 'emacs' from terminal. M-x server-start Run 'emacsclient -c' from terminal. Effect: Theme applied. Scenario 2. Run 'emacs --daemon' from terminal Run 'emacsclient -c' Effect: Theme is not applied. Why is that? .emacs.d/init.d config: (require 'package) (package-initialize) (defun install-pack (p) "A utility function to help in installing emacs package." (unless (package-installed-p p) (package-install p))) (defun install-packs

C Comment in Emacs - Linux Kernel Style

人走茶凉 提交于 2019-12-04 10:17:18
I'm using (setq-default comment-style 'multi-line) and my region comments, when doing M-; , are: /* void main() * { * int i; * int b; * printf("format string"); * } */ But I want them to look like this: /* * void main() * { * int i; * int b; * printf("format string"); * } */ What do I have to change? Try with: (setq comment-style 'extra-line) Geyslan G. Bem Complementing the anler answer and answering my own question. To use the Linux Kernel commenting Style [1] in emacs, just set this variable in your .emacs/init.el : (setq comment-style 'extra-line) To comment/uncomment use M - ; after