index rss mastodon twitter github linkedin email
Álvaro Ramírez
sponsor

Álvaro Ramírez

14 February 2016 Defined elisp variables matching regexp

You can use "M-x apropos-variable" to get documentation for variables matching a pattern. For more flexibility, some elisp can help with getting a list of all variables matching a regexp:

(defun ar/variables-matching-pattern (pattern)
  "Get a list of all variables matching PATTERN."
  (let ((matched-variables '()))
    (mapatoms
     (lambda (symbol)
       ;; Symbol is variable?
       (when (and (boundp symbol)
                  (string-match pattern (symbol-name symbol)))
         (add-to-list 'matched-variables symbol))))
    matched-variables))

(let ((variables ""))
  (mapc (lambda (variable-symbol)
          (setq variables
                (concat variables
                        (format "%s => %s\n"
                                (symbol-name variable-symbol)
                                (symbol-value variable-symbol)))))
        (ar/variables-matching-pattern "^tern-.*"))
  variables)
tern-mode-keymap => (keymap (3 keymap (4 . tern-get-docs) (3 . tern-get-type) (18 . tern-rename-variable)) (27 keymap (44 . tern-pop-find-definition) (67108910 . tern-find-definition-by-name) (46 . tern-find-definition)))
tern-update-argument-hints-async => nil
tern-known-port => nil
tern-mode => nil
tern-activity-since-command => -1
tern-project-dir => nil
tern-last-point-pos => nil
tern-last-completions => nil
tern-explicit-port => nil
tern-idle-time => 2.5
tern-find-definition-stack => nil
tern-last-argument-hints => nil
tern-idle-timer => nil
tern-server => nil
tern-last-docs-url => nil
tern-buffer-is-dirty => nil
tern-command-generation => 0
tern-flash-timeout => 0.5
tern-update-argument-hints-timer => 500
tern-mode-hook => nil
tern-command => (tern)