help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Using "Emacs Configure" **and** modifying .emacs


From: John Mastro
Subject: Re: Using "Emacs Configure" **and** modifying .emacs
Date: Mon, 14 Aug 2017 16:17:04 -0700

Emanuel Berg <moasen@zoho.com> wrote:
> Here is something that can help speed up the
> tracking down of user variables in code already
> written:
>
>     (defun echo-user-variable ()
>       (interactive)
>       (let ((var (variable-at-point t))) ; ANY-SYMBOL
>         (if (custom-variable-p var)
>             (message "user variable")
>           (message "something else") )))
>     (defalias 'euv 'echo-user-variable)

Here's a quick & dirty [and wrong in some way(s)] command you could use
to actively search for such variables. It only reports ones that, in
addition to meeting `custom-variable-p', have a `custom-set' property.

(cl-defun find-custom-set-variable ()
  (interactive)
  (let (sexp)
    (while (and (re-search-forward "([ \t]*set[fq]\\_>" nil t)
                (not (or (nth 3 (syntax-ppss))
                         (nth 4 (syntax-ppss))))
                (setq sexp (ignore-errors
                             (save-excursion
                               (goto-char (match-beginning 0))
                               (read (current-buffer))))))
      (cl-loop for (sym val) on (cdr sexp) by #'cddr
               when (and (custom-variable-p sym) (get sym 'custom-set))
               do (progn (message "`%s'" sym)
                         (cl-return-from find-custom-set-variable))))))

Besides any errors, one limitation is that it will of course only work
for variables defined in packages that have been loaded.

        John



reply via email to

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