12

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

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

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

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 receive quite a long output in Backtrace :-(

2
  • Looks like you just have a spacing error. Remove the extra spacing of: LaTeX-clean- intermediate-suffixes and you should be fine. Commented Jul 20, 2012 at 6:01
  • That was somehow a copy and paste error, I didn't have this in the code. I'll change the above. Commented Jul 20, 2012 at 6:27

3 Answers 3

32

As assem pointed out there seems to be extra whitespace in your code which prevents the otherwise correct invocation of remove.

Note that both delete and remove work for such purposes, as long as the elements of the list can be compared correctly via equal which is used for both of them. If you want to compare using eq instead, use the functions delq or remq.

The main differences between delete and remove (or delq and remq respectively) is that delete removes the given element by side effect, i.e., changes the given list in place, while remove does not but instead returns a copy of the given list with the element removed.

(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 above code, you'll find the following output in your *Message* buffer:

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 called delete on it, it has changed.

Sign up to request clarification or add additional context in comments.

Comments

8

The error you see is not due to manipulations of the list but caused by a wrong usage of eval-after-load. This function allows only two parameters: (eval-after-load FILE FORM). So your snippet 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"))))

(as multiple assignments are allowed in a single setq statement) or the more general variant (subsuming as many forms as you wish within a single 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")))))

1 Comment

you could also use with-eval-after-load which adds the progn and quoting for you: (with-eval-after-load 'latex ... ...)
3

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))

2 Comments

I still get the debug(error (wrong-number-of-arguments... error
Since, per the other answer, delete modifies lists in place, the setq is not necessary.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.