Function: custom-save-delete
custom-save-delete is a byte-compiled function defined in
cus-edit.el.gz.
Signature
(custom-save-delete SYMBOL)
Documentation
Delete all calls to SYMBOL from the contents of the current buffer.
Leave point at the old location of the first such call, or (if there were none) at the end of the buffer.
This function does not save the buffer.
Source Code
;; Defined in /usr/src/emacs/lisp/cus-edit.el.gz
;; Editing the custom file contents in a buffer.
(defun custom-save-delete (symbol)
"Delete all calls to SYMBOL from the contents of the current buffer.
Leave point at the old location of the first such call,
or (if there were none) at the end of the buffer.
This function does not save the buffer."
(goto-char (point-min))
;; Skip all whitespace and comments.
(while (forward-comment 1))
(or (eobp)
(save-excursion (forward-sexp (buffer-size)))) ; Test for scan errors.
(let (first)
(catch 'found
(while t ;; We exit this loop only via throw.
;; Skip all whitespace and comments.
(while (forward-comment 1))
(let ((start (point))
(sexp (condition-case nil
(read (current-buffer))
(end-of-file (throw 'found nil)))))
(when (and (listp sexp)
(eq (car sexp) symbol))
(delete-region start (point))
(unless first
(setq first (point)))))))
(if first
(goto-char first)
;; Move in front of local variables, otherwise long Custom
;; entries would make them ineffective.
(let ((pos (point-max))
(case-fold-search t))
(save-excursion
(goto-char (point-max))
(search-backward "\n\^L" (max (- (point-max) 3000) (point-min))
'move)
(when (search-forward "Local Variables:" nil t)
(setq pos (line-beginning-position))))
(goto-char pos)))))