elisp

If frame named “xyz” exists, then switch to that frame

不羁的心 提交于 2019-11-29 08:41:15
Could someone please give me hand with a function that detects whether a frame named "xyz" exists, and if so, then switch to that frame. I'm using frame-cmds to give each frame a user-defined name: http://www.emacswiki.org/emacs/frame-cmds.el I would imagine it is similar to a buffer, but I'm not finding anything on Google. Here is the buffer function: (defun buffer-exists (bufname) (not (eq nil (get-buffer bufname)))) (defun lawlist-switch-to-buffer-xyz () (interactive) (if (buffer-exists "xyz") (switch-to-buffer "xyz") )) Here is a semi-related post: https://superuser.com/questions/358037

Emacs indent level global override

别说谁变了你拦得住时间么 提交于 2019-11-29 07:53:07
I want to set the indentation mode to tabs only, with a 4 character width for any mode. This seems like a trivial thing, but I have not had success. Every mode seems to have its own variables and options. I've tried doing this for Perl and R without success. Things that have not worked: (setq-default tab-width 4) (setq standard-indent 4) (setq-default r-indent-level 4) (setq perl-indent-level 4) (setq c-basic-offset 4) works for c-mode but nothing else. Am I forgetting something? Did I set the wrong variables? Is there no such option? I work with a variety of languages (R, Perl, sh, C/C++ etc.

How do I bind a key to “the function represented by the following key sequence”?

。_饼干妹妹 提交于 2019-11-29 06:52:38
I'm just starting to learn emacs (woohoo!) and I've been mucking around in my .emacs quite happily. Unfortunately, I don't know Lisp yet, so I'm having issues with the basics. I've already remapped a few keys until I fix my muscle memory: (global-set-key (kbd "<f9>") 'recompile) That's fine. But how can I tell a key to 'simulate pressing several keys'? For instance, I don't know, make <f1> do the same as C-u 2 C-x } (widen buffer by two chars). One way is to look up that C-x } calls shrink-window-horizontally , and do some sort of lambda thing. This is of course the neat and elegant way (how

How to remove a key from a minor-mode keymap in Emacs?

只愿长相守 提交于 2019-11-29 04:51:17
问题 I have globally assigned C-c/ to ace-jump-mode but reftex-mode (a minor mode for citations used with AucTeX) overrides this key with some function I never use. I tried local-unset-key but it only unbinds keys from the current major mode's map. How do I remove C-c/ from reftex-mode-map without making changes to reftex.el? 回答1: You can change an existing key map using define-key . By passing nil as the function to call, the key will become unbound. I guess that you should be able to do

Latex, Emacs: automatically open *TeX Help* buffer on error and close it after correction of the error?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-29 04:27:11
I use the function TeX-parse-error defined by Ivan Andrus at the bottom of Emacs latexmk function throws me into an empty buffer in order to automatically open the *TeX Help* buffer when there was an error during the compilation ( C-c C-c ). After correcting an error and compiling again, the *TeX Help* buffer remains open (although the error has been corrected). Is there any way to adjust the function (unfortunately, I'm not experienced in elisp programming) so that the *TeX Help* buffer is closed if the error was resolved and updated (and still open) if the error wasn't resolved? That would

In elisp, how do I put a function in a variable?

♀尐吖头ヾ 提交于 2019-11-29 03:22:54
I want to allow the user to choose their own command in the "customize" emacs backend (and generally be able to store an executable form name in a variable) but this does not work : (defun dumb-f () (message "I'm a function")) (defvar my-function "dumb-f") (my-function) ==> Debugger entered--Lisp error: (invalid-function "dumb-f") (setq my-function 'dumb-f) (my-function) ==> Debugger entered--Lisp error: (invalid-function "dumb-f") I tried various forms, but still no luck, and I'm having a hard time searching for it, I get kilopages of results about functions and variables, but none about how

Are there any emacs key combinations reserved for custom commands?

时间秒杀一切 提交于 2019-11-29 03:04:57
问题 If I want to create a custom key combination to run a command, are there any keyboard shortcuts reserved for this? I always find it difficult to decide on which shortcut to override because I'm not sure what commands I shouldn't override and which commands plugins I may install in the future will try to set. 回答1: I would suggest using unbound. It was made for just this type of scenario. Once you have it required in your emacs config, typing the following will list possible unbound keys for

How to Create a Temporary Function in Emacs Lisp

巧了我就是萌 提交于 2019-11-29 02:56:59
I'm making some tedious calls to a bunch of functions, but the parameters will be determined at runtime. I wrote a simple function to keep my code DRY but giving it a name is unnecessary. I don't use this function anywhere else. I'm trying to do it the way I would in Scheme, but I get a void-function error: (let ((do-work (lambda (x y z) (do-x x) (do-y y) ;; etc ))) (cond (test-1 (do-work 'a 'b 'c)) (test-2 (do-work 'i 'j 'k)))) I could stick it all into an apply (e.g., (apply (lambda ...) (cond ...)) ) but that isn't very readable. Is there a better way? Like other lisps (but not Scheme),

Emacs key binding for multiple commands

泪湿孤枕 提交于 2019-11-29 02:48:20
问题 I'm new to emacs, and have a rookie question. I can bind a key to a particular function by (global-set-key (kbd "C-c a b c") 'some-command) , where some-command is a function. How can I invoke two functions (say some-command and some-other-command ) with one key binding? Thanks a lot! 回答1: You can define your own function which call the two functions, and bind the key to your own function. Or use a simple lambda: (global-set-key (kbd "C-c a b c") (lambda () (interactive) (some-command) (some

Setting auto-mode-alist in emacs

六眼飞鱼酱① 提交于 2019-11-29 01:46:09
问题 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