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

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

Re: Choose whether to load *.el or *.elc by modification time.


From: Thien-Thi Nguyen
Subject: Re: Choose whether to load *.el or *.elc by modification time.
Date: Sun, 03 Jul 2016 00:03:19 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

() Davin Pearson <address@hidden>
() Mon, 20 Jun 2016 00:10:35 -0700 (PDT)

   (setq name-sans-extension (substring file 0 (match-beginning 0)))
   (setq name-plus-el        (concat name-sans-extension ".el" ))
   (setq name-plus-elc       (concat name-sans-extension ".elc"))
   (setq date-el  (nth 5 (file-attributes name-plus-el )))
   (setq date-elc (nth 5 (file-attributes name-plus-elc)))
   (setq time-el  (+ (* 65536.0 (or (car date-el ) 1)) (or (cadr date-el ) 0)))
   (setq time-elc (+ (* 65536.0 (or (car date-elc) 1)) (or (cadr date-elc) 0)))
   (if (> time-el time-elc) ...)

These are fine variable names for this piece of advice.
Unfortunately, in using ‘setq’ to bind values to them, they will
now be visible outside of the advice, even after it has finished.
Although that may not produce any immediate problems, it's anyway
better to avoid even the possibility of (this kind of) weirdness.
You can do that by using the ‘let*’ special form:

 (let* ((name-sans-extension (substring ...))
        (name-plus-el (concat ...))
        ...
        (time-elc (+ ...)))
   (if (> time-el time-elc) ...))

See (info "(elisp) Local Variables") for details.

-- 
Thien-Thi Nguyen -----------------------------------------------
  (if you're human and you know it) read my lisp:
    (defun responsep (type via)
      (case type
        (technical (eq 'mailing-list via))
        ...))
---------------------------------------------- GPG key: 4C807502

Attachment: signature.asc
Description: PGP signature


reply via email to

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