elisp

The function to show current file's full path in mini buffer

对着背影说爱祢 提交于 2019-11-29 18:56:10
I need to get the full path of the file that I'm editing with emacs. Is there a function for that? If not, what would be the elisp function for getting that? How can I copy the result (path name) to a clipboard so that I can reuse it? I'm using Mac OS X and Aqumacs. (setq filepath (get-fullpath-current-file)) ??? (copy-to-clipboard 'filepath) ??? ADDED (defun show-file-name () "Show the full path file name in the minibuffer." (interactive) (message (buffer-file-name)) (kill-new (file-truename buffer-file-name)) ) (global-set-key "\C-cz" 'show-file-name) Combining the two answers that I got, I

How to have Emacs auto-refresh all buffers when files have changed on disk?

亡梦爱人 提交于 2019-11-29 18:49:48
I have a non-emacs global search and replace function that causes my disk files to become more up-to-date than my emacs buffers (en masse). Is there any way to tell emacs to refresh all the buffers from disk in one fell swoop, instead of having to do each one individually by reloading the file? Thanks! D Ashwin (global-auto-revert-mode t) in your .emacs . Here is an alternative if you are using Emacs GUI (Mine is GNU Emacs 25.1.1 on Windows 7): Click "Options" in menubar Select "Customize Emacs" Select "Saved Options" Then you should see a search field where you enter "global-auto-revert-mode"

elisp functions as parameters and as return value

柔情痞子 提交于 2019-11-29 18:27:08
问题 I have the following code (defun avg-damp(f) #'(lambda(x) (/ (+ (funcall f x) x) 2.0))) A call (funcall (avg-damp #'(lambda(v) (* v v))) 10) returns 55.0 (the correct value) in SBCL but crashes with the following stack in emacs lisp Debugger entered--Lisp error: (void-variable f) (funcall f x) (+ (funcall f x) x) (/ (+ (funcall f x) x) 2.0) (lambda (x) (/ (+ ... x) 2.0))(10) funcall((lambda (x) (/ (+ ... x) 2.0)) 10) eval((funcall (avg-damp (function ...)) 10)) eval-last-sexp-1(nil) eval-last

In Elisp, how to get path string with slash properly inserted?

孤者浪人 提交于 2019-11-29 18:23:15
问题 I am manually constructing path strings in Elisp by concatenating partial paths and directory names. Unfortunately sometimes the paths end with slash, sometimes not. Therefore, I need to insert slash before concatenating a directory name when necessary but not otherwise. What's a good way to do this? 回答1: (file-name-as-directory dir) will return directory path dir with a trailing slash, adding one if necessary, and not otherwise. If you had your sequence of partial paths in a list, you could

Get Emacs to ignore contents of \Sexpr{} command in Sweave document to prevent incorrect $-based syntax highlighting

萝らか妹 提交于 2019-11-29 17:29:55
问题 When editing an Sweave document in LaTeX (using the Noweb mode), Emacs knows to "ignore" code that is in <<>>= blocks. However, for interstitial \Sexpr{} blocks, this isn't the case. Given that R references by columns via '$' and LaTeX uses $ to set-off equations, these \Sexpr{} blocks often break the syntax highlighting, like so: I have a very rudimentary understanding the elisp & Emacs syntax highlighting, but my hope is that it might be possible to add something to .emacs that will disable

How to check if a function (e.g. server-running-p) is available under Emacs?

霸气de小男生 提交于 2019-11-29 16:57:02
问题 I'm trying to check if server-running-p is available in my .emacs file before calling it. I already have the following: (if (not (server-running-p)) (server-start)) But on some computers where I use Emacs, calling (server-running-p) gives an error because said call is not available. So I want to check if server-running-p is available before calling it. I thought boundp would do the try, but calling (boundp 'server-running-p) return nil even though the (server-running-p) call succeeds. What's

How to refer to the file currently being loaded in Emacs Lisp?

故事扮演 提交于 2019-11-29 16:46:46
问题 I am looking to include a reference to a non-elisp file (a small Python program), and would like to be able to say "it is in the same directory as the current file, but with a different file name." In many scripting languages, there are things like __FILE__ (in PHP) for getting an absolute path to the current file. If the file to be included is in the load-path , then I can find it with (locate-library "file.py" t) , but I'm kind of stuck if the file is not in the load path. So is there a way

Colorize current line number

你说的曾经没有我的故事 提交于 2019-11-29 15:39:35
问题 I am using global-linum-mode for line numbers. It would be nice if the line number of the current line was highlighted with different color (and/or also different background). Anybody has an idea how to achieve this? Thank you! 回答1: I've derived this answer from my previous answer to Relative Line Numbers In Emacs, as it deals with the same issue of remembering the current line number during the linum format process. I'm inheriting from the linum face, but using the background colour from hl

Passing arguments to elisp script. Again

人走茶凉 提交于 2019-11-29 15:15:06
How can I pass arguments -q -d -Q -t -L -fg -bg --color etc? Doing something like emacs --script -Q <scriptname> <arguments> definetely will not pass arguments, which are used in emacs. So how to do it? phils Based on your comment on Rafael Ibraim's answer, I'm adding this second answer, as I think my first answer is also mis-interpreting your question (and if so, you may wish to edit the question to provide clarification). You can prevent Emacs from processing command line arguments using the usual approach of an 'empty' argument: -- So if you run this: emacs --script (filename) -- -Q Emacs

Emacs Lisp: difference between (function (lambda …)) and (lambda …)?

巧了我就是萌 提交于 2019-11-29 14:46:07
问题 What is the difference between (function (lambda ...)) and (lambda ...) and '(lambda ...) ? It seems three are interchangeable in a lot of cases. 回答1: They are pretty interchangeable. The answer is that function enables the lambda to be byte compiled, whereas the other two do not (and are equivalent). Note: this does not mean that function actually byte compile the lambda. How might one figure that out? A little Emacs lisp introspection provides some clues. To start: C-h f function RET :