[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: add-to-list: factorization?
From: |
Vladimir Lomov |
Subject: |
Re: add-to-list: factorization? |
Date: |
Wed, 20 May 2020 17:10:55 +0800 |
Hello,
** Denis Bitouzé <address@hidden> [2020-05-20 10:47:06 +0200]:
> Hi,
> in my `.emacs`, I have something like the following:
> ┌────
> │ (setq TeX-auto-save t)
> │ (setq TeX-parse-self t)
> │ (setq-default TeX-master nil)
> │
> │ (setq LaTeX-verbatim-environments-local '("foo"
> │ "bar"
> │ "baz"
> │ ))
> │ (with-eval-after-load "latex"
> │ (add-to-list 'LaTeX-indent-environment-list '("foo"
> current-indentation))
> │ (add-to-list 'LaTeX-indent-environment-list '("bar"
> current-indentation))
> │ (add-to-list 'LaTeX-indent-environment-list '("baz"
> current-indentation)))
> └────
> but with a much longer list than only:
> ┌────
> │ "foo"
> │ "bar"
> │ "baz"
> └────
> About `add-to-list`, would it be possible to make a factorization in
> order to not repeat :
> 1. neither `'LaTeX-indent-environment-list '` ;
> 2. nor ` current-indentation` ?
> The ultimate ideal goal would be to not have to maintain in two
> different places the list:
> ┌────
> │ "foo"
> │ "bar"
> │ "baz"
> └────
> On a French forum where I asked this question, I got the answer.
> ┌────
> │ (setq LaTeX-verbatim-environments-local '("foo"
> │ "bar"
> │ "baz"
> │ ))
> │ (dolist (env LaTeX-verbatim-environments-local)
> │ (add-to-list 'LaTeX-indent-environment-list (list env
> #'current-indentation)))
> └────
> If used in my `.emacs`, I get the following error at restart:
> Debugger entered--Lisp error: (void-variable LaTeX-indent-environment-list)
> (member x LaTeX-indent-environment-list)
> (if (member x LaTeX-indent-environment-list) LaTeX-indent-environment-list
> (setq LaTeX-indent-environment-list (cons x LaTeX-indent-environment-list)))
> (let* ((x (list env (function current-indentation)))) (if (member x
> LaTeX-indent-environment-list) LaTeX-indent-environment-list (setq
> LaTeX-indent-environment-list (cons x LaTeX-indent-environment-list))))
> (while --dolist-tail-- (setq env (car --dolist-tail--)) (let* ((x (list env
> (function current-indentation)))) (if (member x
> LaTeX-indent-environment-list) LaTeX-indent-environment-list (setq
> LaTeX-indent-environment-list (cons x LaTeX-indent-environment-list)))) (setq
> --dolist-tail-- (cdr --dolist-tail--)))
> (let ((--dolist-tail-- LaTeX-verbatim-environments-local) env) (while
> --dolist-tail-- (setq env (car --dolist-tail--)) (let* ((x (list env
> (function current-indentation)))) (if (member x
> LaTeX-indent-environment-list) LaTeX-indent-environment-list (setq
> LaTeX-indent-environment-list (cons x LaTeX-indent-environment-list)))) (setq
> --dolist-tail-- (cdr --dolist-tail--))))
> eval-buffer(#<buffer *load*> nil "/home/bitouze/.emacs" nil t) ; Reading
> at buffer position 397
> load-with-code-conversion("/home/bitouze/.emacs" "/home/bitouze/.emacs" t t)
> load("~/.emacs" t t)
> #f(compiled-function () #<bytecode 0x1d8f61>)()
> command-line()
> normal-top-level()
Did you try to wrap (dolist...) by (with-eval-after-load...) as above?
> Do you understand what's going on and how I can make a factorization on
> `add-to-list`?
> Thanks!
---
WBR, Vladimir Lomov
--
He who knows others is wise.
He who knows himself is enlightened.
-- Lao Tsu
signature.asc
Description: PGP signature