elisp

How can I filter compilation output only for a specific mode or buffer in Emacs?

I have a HTML page, with html-mode enabled. I call function sgml-validate to check for any markup errors. It's based on compilation-mode. I want to remove some warnings from the compilation output, so I wrote a function and hooked it to compilation-filter-hook (this variable is not documented, but compilation-filter invokes it). Everythi...

Emacs Lisp syntax highlighting

I want to write a syntax highlighting extension for Emacs, but I Googling of variations on "emacs syntax highlight tutorial" have all failed. How do I go about learning how to write an Emacs highlighter? What good resources are there for learning how to do such things? ...

How do I run a command just after the emacs frame has been rendered?

I'm trying to figure out how to use Emacs Code Browser (ECB) and one of the things you can do with it is set ecb-windows-width to decide how wide the ecb windows are. The problem is this sequence: Frame pops up on screen. ecb-activate gets called, scaled according to ecb-windows-width. default-frame-alist parameters kick in, frame gets...

How do I intercept Ctrl-G in Emacs

I have a elisp script for Emacs that I want to do some clean up in if a user hits Ctrl-G. I use 'read-event' to catch all events, but this does not catch the Ctrl-G. When Ctrl-G is hit, it just stops execution. In XEmacs, when you call next-command-event it will give you all events including when a user hits Ctrl-G. There must be som...

Emacs - Error when calling (server-start)

I am currently using GNU Emacs 23.0.93.1 in Windows Vista SP1. In my .emacs file I make a call to (server-start) and that is causing an error with the message The directory ~/.emacs.d/server is unsafe. Has anyone seen this and know a fix or workaround? ... other than leaving server turned off ;) Here is the stack trace: Debugger enter...

Run sgml-pretty-print when opening an xml file in emacs?

I can currently use sgml-pretty-print to pretty print an xml file in emacs, but it's a manual process: M-< C-space M-> M-x sgml-pretty-print I'd like this to happen automatically (or at least have some option to do so). I'm new to emacs/elisp, and do not understand how: emacs knows what code to run when you open a file (does this ...

How do I fix the cursor to the middle of the screen in Emacs, so that the page moves, not the cursor?

I'd like to fix the cursor to the centre line of the screen, so that when I press Ctrl-N or Ctrl-P, the page itself moves up or down, and the cursor stays still. Has anyone got any tips on how to achieve this? Thanks Ed ...

ELisp: Check if string is already in list

How do I check if a string is already in a list in ELisp? I need to check if a certain path string is already in exec-path, and then add it to that list if it's not. Thanks! ...

Resources for learning Emacs

I'd like to learn Emacs, and was wondering if anyone had any good resources (free or otherwise) to recommend. I'm mostly interested in programming Emacs, starting from the basics, and lots of "exercises". I have used Emacs and most of its editing features, although I'm a bit rusty so a very quick refresher on that would be useful as well...

How can I spot subtle Lisp syntax mistakes?

I'm a newbie playing around with Lisp (actually, Emacs Lisp). It's a lot of fun, except when I seem to run into the same syntax mistakes again and again. For instance, here's something I've encountered several times. I have some cond form, like (cond ((foo bar) (qux quux)) ((or corge (grault warg)) (fred) (t xyzzy))) ...

In Emacs, how do I change the minibuffer completion list window?

I would like to set a specific window for the minibuffer completion list. Currently, I have 3 windows in this configuration: ______ | | | |____| | |____|_| In this case, I'd like to use the bottom left window for the minibuffer completion list. Currently, it seems to a window at random, and most of the time it likes to use the fa...

Can I use ido-completing-read instead of completing-read everywhere?

I'm a big fan of ido-mode, so much so that I would like to use it for things like describe-function or find-tag and so on, without having to write something like in "Can I get ido-mode-style completion for searching tags in Emacs?" for each one. Both (defalias completing-read ido-completing-read) and (setf 'completing-read 'ido-comp...

What is the difference between `global-set-key` and `define-key global-map` in Emacs

If you had two snippets: (global-set-key "\C-d" delete-char) and (define-key global-map "\C-d" delete-char) Is there a difference between the two? If so, when would you use one over the other? ...

How can you write multiple statements in elisp 'if' statement?

In elisp, there is an 'if' case where I would like to perform many different things: (if condition (do-something) (do-something-else) ...) However, (do-something-else) is executed in the else-case only. How can you specify a block of instructions to execute? For example: (if condition (begin (do-something) ...

In emacs XML mode, how to pretty-format an XML schema file?

I want to automatically format an XML schema definition file. All the normal pretty-print stuff: linebreaks after end-element, indentiing. I have seen this answer, and this elisp, which gives me the basics. Beyond what is there, though, I would like line-breaks between attributes within angle-brackets. Like so. Before: <s:schema el...

How can I tell in elisp if Emacs is using X?

I have some items in my .emacs that I don't want to run if I ran emacs -nw. How can I tell in elisp if that is the case? (edited to change -nox to -nw --- where was my brain?) ...

In emacs, how do I highlight the current line in the current frame only?

In Emacs (23 on Mac Leopard), I've discovered how to highlight the current line with hl-line-mode, but when using it globally in all buffers, it highlights the current line in all buffers in all frames. I'd like to be able to highlight the current line (or at least have a different face for it) in only the currently active buffer. I'm ...

How can I check if a file exists using emacs lisp?

I would like emacs to mark files that are generated as read-only when they're opened. The part of the puzzle that I'm missing is how to check if a file "exists". I currently have the following: ;; ;; get file extension ;; (defun get-ext (file-name) (car (cdr (split-string file-name "\\.")))) ;; ;; get the base name of the file ;; ...

Emacs 23, OS X, multi-tty and emacsclient

How can I get emacs 23 working nicely in multi-tty mode on OS X? I've added (server-start) to my .emacs, and have discovered that running /Applications/Emacs.app/Contents/MacOS/bin/emacsclient -n ~/myfile.txt will open it in my emacs.app, but it doesn't bring emacs to the front. So, how can I get emacs.app to come to the front when I r...

Modify mode-compile.el to handle MS-Windows paths with imbedded blanks?

Can anyone suggest a modification of mode-compile.el that will make it work better on Windows? My specific issue is handling of path names that contain blanks. I'm working on code in Ruby, using "GNU Emacs 22.2.1 (i386-mingw-nt5.1.2600) of 2008-03-26 on RELEASE" with mode-compile.el version: 2.29 (Last modified: 2006/12/01 13:52:47) T...