[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Disabling automatic reindentation of the current line after a newlin
From: |
Emanuel Berg |
Subject: |
Re: Disabling automatic reindentation of the current line after a newline |
Date: |
Wed, 26 Oct 2022 08:04:47 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
Stefan Monnier via Users list for the GNU Emacs text editor wrote:
> To some extent, I think `setq` should basically
Note the word "basically" ...
> never be used other than on lexical variables: for
> non-lexical variables, we should either use `setq-default`
> or `setq-local` but never this `setq` which does sometime
> one thing and sometimes the other.
Because, most often it works like this, `setq' sets the
default/global value if that is set, but the _local_ if that
or both are set, and if neither are, it sets the default -
unless the variable is defined with DEFVAR_PER_BUFFER in C or
`make-local-variable' in Elisp, that means it "Automatically
becomes buffer-local when set" so then setq will be like
`setq-local' and not `setq-default' all tho none are
set. Phew!
Yes, most often ... but not always?
; don't use `setq' here, @#$&%!
(setq-local lexical-binding nil)
; because `lexical-binding' is dynamic/special, i.e. the variable itself
(special-variable-p 'lexical-binding)
; this function relies on a dynamic and/or special variable `n'
(defun use-var ()
n)
; formal parameters are dynamic under dynabound
(defun lexfun (n)
(setq n 1)
(special-variable-p 'n) ; but not special since they are not global
(use-var) )
;; (lexfun 2) ; 1
(special-variable-p 'n) ; nil
--
underground experts united
https://dataswamp.org/~incal