[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: refactor emacs lisp code, macros, byte-compiling, fun fun fun
From: |
Stefan Monnier |
Subject: |
Re: refactor emacs lisp code, macros, byte-compiling, fun fun fun |
Date: |
Wed, 28 Mar 2012 19:23:24 -0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) |
> (defadvice find-function-search-for-symbol (after oxy-adv1 last (symbol type
> library) activate)
> "mark system files `read-only'"
> (with-current-buffer (car ad-return-value)
> (when (or (backup-file-name-p buffer-file-name)
> (not (string-match (concat "\\`" (regexp-quote
> (expand-file-name "~")))
> buffer-file-name)))
> ;; (view-mode 1)
> (setq buffer-read-only t))))
> (defadvice find-variable-noselect (after oxy-adv2 last (variable &optional
> file) activate)
> "mark system files `read-only'"
> (with-current-buffer (car ad-return-value)
> (when (or (backup-file-name-p buffer-file-name)
> (not (string-match (concat "\\`" (regexp-quote
> (expand-file-name "~")))
> buffer-file-name)))
> (setq buffer-read-only t))))
Visiting files to which you do not have write access should already put
them in read-only mode. Are you running Emacs as root by any chance?
> I want to factor out the common logic in the defadvice, *without* polluting
> the global name-space.
You can prefix your global definitions with "lewang-" or something like
that (other people use "my-").
> But macrolet does dynamic binding, so it's not what I want. And (do-it)
> still appears in the byte-code. Is there something that does what I want?
Maybe something like:
(eval-when-compile
(defmacro blabla blibli))
...blabla...
will avoid including "blabla" in the byte-code, but I won't
guarantee it.
Stefan
- Re: refactor emacs lisp code, macros, byte-compiling, fun fun fun,
Stefan Monnier <=