[Top][All Lists]

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

Re: [AUCTeX-devel] Adding key/vals to predefined ones

From: Tassilo Horn
Subject: Re: [AUCTeX-devel] Adding key/vals to predefined ones
Date: Mon, 02 Mar 2015 09:29:54 +0100
User-agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/25.0.50 (gnu/linux)

Arash Esbati <address@hidden> writes:

>> Why the (unless (null ...) ...) checks?  That's the same as (when
>> ...)  but doubly negated, no?  And why do you need that anyhow?  The
>> (dolist ...) doesn't need it.
> My idea was to gain some speed by checking if
> `LaTeX-enumitem-SetEnumitem(Key|Value)-list' are changed and then go
> through the (dolist ...) action.  I'm not sure how popular these
> features of `enumitem' are.

You won't gain any speed with that.  `dolist' does that anyway, and in
the end it doesn't matter anyhow if a style hook takes 50ms or 49ms to

>> Oh, and I guess the (apply 'append ...) is for flattening the *-list
>> vars.  Instead, please use the functions of the same name which return
>> the keys/key-vals in a uniform format so you don't need those hacks.
> I had that but it turned out that the function swallows items, example:
> Am I missing something?

Ah, indeed.  The auto *-list functions call `TeX-auto-list-information'
which sorts and uniquifies the elements, i.e., if the alist has two
entries with car "foo", then only one of them (the one with the longer
cdr) is kept.

So I suggest you use

--8<---------------cut here---------------start------------->8---
(defvar LaTeX-enumitem-SetEnumitemValue-regexp
    (0 1 2) LaTeX-auto-enumitem-SetEnumitemValue)
  "Matches the arguments of `\\SetEnumitemValue' from `enumitem'
--8<---------------cut here---------------end--------------->8---

as auto regex.  Note that the list of matches now contains match 0 as
car.  Match 0 is the complete matching text.  You only use it here to
make sure the cars of the elements are unique.  Then the values returned


are triples (complete-match key value) where you simply ignore the first

>> And please don't use `add-to-list' on local variables.  Instead, use
>> `pushnew' (with :test #'string= in case its a list of strings), e.g.,
>>   (pushnew opts (list key (list val)) :test #'string=)
>> instead of
>>   (add-to-list 'opts (list key (list val)))
> Thnx, I should have read the doc-string from `add-to-list' more carefully. 
> I have now,
>    (cl-pushnew (list key (list val)) opts :test #'equal)

Use `pushnew' which is an alias to `cl-pushnew' on Emacs.  XEmacs and
Emacs versions less than 24.x don't have `cl-pushnew'.

> I will adapt the rest this week, hopefully I can make a patch next
> weekend.


> Thank you for your patience.

You're welcome.


reply via email to

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