Emacs lisp: How to remove / delete list item?

I tried my first steps with emacs lisp to remove the "\\.synctex\\.gz" element from LaTeX-clean-intermediate-suffixes :

 (eval-after-load 'latex '(setq my-LaTeX-clean-intermediate-suffixes (remove '"\\.synctex\\.gz" LaTeX-clean-intermediate-suffixes)); that not working '(setq LaTeX-clean-intermediate-suffixes (append my-LaTeX-clean-intermediate-suffixes (list "-blx\\.bib" "\\.run\\.xml")))) 

How can I remove this item here? I found remove and delete , tried both of them, but I get the error wrong-number-of-arguments .

Update

I tried this:

 (eval-after-load 'latex (setq LaTeX-clean-intermediate-suffixes (delete "\\.synctex\\.gz" LaTeX-clean-intermediate-suffixes)) '(setq LaTeX-clean-intermediate-suffixes (append LaTeX-clean-intermediate-suffixes (list "-blx\\.bib" "\\.run\\.xml")))) 

but I get a rather long output in Backtrace: - (

+6
source share
3 answers

The error you see is not due to list manipulation, but due to improper use of eval-after-load. This function allows only two parameters: (eval-after-load FILE FORM) . Therefore, your fragment should read either

 (eval-after-load 'latex '(setq LaTeX-clean-intermediate-suffixes (delete "\\.synctex\\.gz" LaTeX-clean-intermediate-suffixes) LaTeX-clean-intermediate-suffixes (append LaTeX-clean-intermediate-suffixes (list "-blx\\.bib" "\\.run\\.xml")))) 

(since multiple assignments are allowed in one setq job) or a more general option (including as many forms as you wish, within one progn ):

 (eval-after-load 'latex '(progn (setq LaTeX-clean-intermediate-suffixes (delete "\\.synctex\\.gz" LaTeX-clean-intermediate-suffixes)) (setq LaTeX-clean-intermediate-suffixes (append LaTeX-clean-intermediate-suffixes (list "-blx\\.bib" "\\.run\\.xml"))))) 
+4
source

As Assem noted, there are extra spaces in your code that prevent remove from being mishandled.

Please note that both delete and remove work for such purposes, if the list items can be correctly compared using equal , which is used for both of them. If you want to compare using eq instead, use the delq or remq .

The main differences between delete and remove (or delq and remq respectively) are that delete deletes this element by side effect, i.e. modifies the given list in place, and remove does not return, but returns a copy of this list with the deleted item.

 (setq list1 '("foo" "bar" "baz")) (setq list2 (remove "bar" list1)) (message "list1: %s" list1) (message "list2: %s" list2) (setq list3 (delete "bar" list1)) (message "list1: %s" list1) (message "list3: %s" list3) 

If you evaluate the code above, in the *Message* buffer you will find the following output:

 list1: (foo bar baz) list2: (foo baz) list1: (foo baz) list3: (foo baz) 

As you can see, after calling remove on list1 it has not changed. But after you wrote delete on it, it has changed.

+12
source

delete should work http://www.gnu.org/software/emacs/manual/html_node/elisp/Sets-And-Lists.html

 (setq LaTeX-clean-intermediate-suffixes (delete "\\.synctex\\.gz" LaTeX-clean-intermediate-suffixes)) 
0
source

Source: https://habr.com/ru/post/920936/


All Articles