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

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

Re: Error: Setting the shell in sh-mode via a local variable does not wo


From: Teemu Likonen
Subject: Re: Error: Setting the shell in sh-mode via a local variable does not work
Date: Wed, 30 Dec 2015 17:19:42 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5.50 (gnu/linux)

I'll add some simple Lisp programming notes that are unrelated to your
discussion. I hope you don't mind. :-)


Emanuel Berg [2015-12-29 02:32:38+01] wrote:

> (let ((modes '(

>      )))
>   (setq auto-mode-alist (append modes auto-mode-alist)) )

There you create a list MODES and then APPEND copies the whole list and
joins it to AUTO-MODE-ALIST. The original list is discarded. No problem,
it's just a configuration code. But in some other situation it might be
good idea to construct the list only once and use NCONC which only
traverses the lists through and modifies last conses to join it to the
next list:

    (let ((modes (list '(a . b)
                       ;; ...
                       )))
      (setq auto-mode-alist (nconc modes auto-mode-alist)))

Or:

    (setq auto-mode-alist
          (nconc (list '(a . b)
                       ;; ...
                       )
                 auto-mode-alist))

I used LIST function because, at least in Common Lisp, literal objects
(like lists created with QUOTE ' or literal strings) shouldn't be
modified. Consequences are undefined.

>     (setq magic-mode-alist '(("# spec.in" . (lambda () (interactive) (progn 
> (sh-mode) (sh-set-shell "rpm"))))))

The PROGN is redundant because LAMBDA has an implicit PROGN:

    (lambda ()
      (interactive)
      (sh-mode)
      (sh-set-shell "rpm"))

-- 
/// Teemu Likonen   - .-..   <https://github.com/tlikonen> //
// PGP: 4E10 55DC 84E9 DFF6 13D7 8557 719D 69D3 2453 9450 ///

Attachment: signature.asc
Description: PGP signature


reply via email to

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