help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RFH] on my first lisp function


From: Francis Moreau
Subject: [RFH] on my first lisp function
Date: Tue, 2 Jun 2009 03:58:21 -0700 (PDT)
User-agent: G2/1.0

Hello,

I finally wrote my first elisp function !

For this first great event, I tried to address something that I always
wanted emacs to do: make the compilation buffer disappear if there
weren't any errors (ok I would like to keep the compilation buffer
also if there're some warnings but it doesn't seems possible).

The code below works pretty well except for one thing: I would like to
make the window disappear if the original frame layout (before
starting the compile command) had only one window so the original
layout is kept.

Does anybody know how to do this ?

Also I use:

(setq str (substring str 0 -1))

to remove the trailing '\n' but I'm not sure if it's the correct way
to do this.

Could anybody confirm ?

Thanks.

----------------------------------

(setq-default compilation-close-delay 1)

(defvar compilation-close-delay 0
  "If 0, do not automatically close the compilation window.
Otherwise, it specifies how long in seconds the compilation
window should be closed after a successful compile command.")

(add-hook 'compilation-finish-functions
     (lambda (buf str)
       ;; FIXME: Remove '\n' in str, is this the correct way ?
       (setq str (substring str 0 -1))

       (when (> compilation-close-delay 0)
          (when (string= "finished" str)
            ;; Unfortunately I don't find a way to know how many
            ;; windows were opened before the compilation buffer
            ;; creation. So I can't use 'delete-windows-on if that
            ;; number is 1.
            (run-at-time compilation-close-delay nil 'replace-buffer-in-
windows buf)))

       (message "%s %s" (buffer-name buf) str)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]