Wednesday, October 26, 2016

Emacs Gurus

I am trying to set up my emacs init file to do these things:

1. A command make which saves all open buffers opens a shell in compilation-mode and does a make in the shell.

2. Bind C-X C-E to make

3. Bind next-error to C-X C-N.

Here's what I have:

(compilation-mode)
(fset 'make
   [escape ?x ?s ?h ?e ?l ?l escape ?x ?c?o?m?p?i?l?a?t?i?o?n?-?m?o?d?e return ?
m ?a ?k ?e return])
(global-set-key (kbd "C-x C-e") 'make)
(global-set-key (kbd "C-x n") 'next-error)

Almost there:

(fset 'make
   [escape ?x?c?o?m?p?i?l?a?t?i?o?n?-?m?o?d?e return escape ?x ?s ?h ?e ?l ?l return ?m ?a ?k ?e return])
(global-set-key (kbd "C-x C-e") 'make)
(global-set-key (kbd "C-x C-n") 'next-error)

The next-error command doesn't seem to work.  Otherwise works.  Nope.  ESC-x make rings a bell in the shell.

Again: almost there.  The C-x C-n binding works, but says no more errors when they are showing in the shell.  C-x C-e works, but beeps at the end.

(fset 'make
   [escape ?x ?s ?h ?e ?l ?l return ?m ?a ?k ?e return])
(global-set-key (kbd "C-x C-e") 'make)
(global-set-key (kbd "C-x C-n") 'next-error)

UPDATE: After much digging, this turned out to be what I needed:

(fset 'make
[escape ?x ?c ?o ?m ?p ?i ?l ?e return])
(global-set-key (kbd "C-x C-e") 'make)
(global-set-key (kbd "C-x C-n") `next-error)

The first two lines define a macro that runs the compile command using make -f in the shell.

The next two lines bind C-X C-E to the make macro and C-X C-N to the next-error command. 






No comments:

Post a Comment