unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#27424: 24.5; [PATCH] commands `apropos-local-variable', `apropos-local-value'
@ 2017-06-18 21:33 Drew Adams
  2017-07-22  8:01 ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Drew Adams @ 2017-06-18 21:33 UTC (permalink / raw)
  To: 27424

[-- Attachment #1: Type: text/plain, Size: 278 bytes --]

See attached patch for two apropos commands for buffer-local variables.

In GNU Emacs 24.5.1 (i686-pc-mingw32)
 of 2015-04-11 on LEG570
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
 `configure --prefix=/c/usr --host=i686-pc-mingw32'

[-- Attachment #2: apropos-2017-06-18.patch --]
[-- Type: application/octet-stream, Size: 2639 bytes --]

diff -u apropos.el apropos-patched.el
--- apropos.el	2017-06-18 14:23:30.026469800 -0700
+++ apropos-patched.el	2017-06-18 14:27:17.814246300 -0700
@@ -514,6 +514,19 @@
   (let ((apropos-do-all (if do-not-all nil t)))
     (apropos-user-option pattern)))
 
+;;;###autoload
+(defun apropos-local-variable (pattern &optional buffer)
+  "Show buffer-local variables that match PATTERN.
+Optional arg BUFFER (default: current buffer) is the buffer to check.
+
+The output includes variables that are not yet set in BUFFER, but that
+will be buffer-local when set."
+  (interactive (list (apropos-read-pattern "buffer-local variable")))
+  (unless buffer (setq buffer  (current-buffer)))
+  (apropos-command pattern nil (lambda (symbol)
+                                 (and (local-variable-if-set-p symbol)
+                                      (get symbol 'variable-documentation)))))
+
 ;; For auld lang syne:
 ;;;###autoload
 (defalias 'command-apropos 'apropos-command)
@@ -795,6 +808,35 @@
    (let ((apropos-multi-type do-all))
      (apropos-print nil "\n----------------\n")))
 
+;;;###autoload
+(defun apropos-local-value (pattern &optional buffer)
+  "Show buffer-local variables whose values match PATTERN.
+This is like `apropos-value', but for only buffer-local variables.
+Optional arg BUFFER (default: current buffer) is the buffer to check."
+  (interactive (list (apropos-read-pattern "value of buffer-local variable")))
+  (unless buffer (setq buffer  (current-buffer)))
+  (apropos-parse-pattern pattern)
+  (setq apropos-accumulator  ())
+  (let ((var             nil))
+    (mapatoms
+     (lambda (symb)
+       (unless (memq symb '(apropos-regexp apropos-pattern apropos-all-words-regexp
+                            apropos-words apropos-all-words apropos-accumulator symb var))
+         (setq var  (apropos-value-internal 'local-variable-if-set-p symb 'symbol-value)))
+       (when (and (fboundp 'apropos-false-hit-str)  (apropos-false-hit-str var))
+         (setq var nil))
+       (when var
+         (setq apropos-accumulator (cons (list symb (apropos-score-str var) nil var)
+                                         apropos-accumulator))))))
+  (let ((apropos-multi-type  nil))
+    (if (> emacs-major-version 20)
+        (apropos-print
+         nil "\n----------------\n"
+         (format "Buffer `%s' has the following local variables\nmatching %s`%s':"
+                 (buffer-name buffer)
+                 (if (consp pattern) "keywords " "")
+                 pattern))
+      (apropos-print nil "\n----------------\n"))))
 
 ;;;###autoload
 (defun apropos-documentation (pattern &optional do-all)

^ permalink raw reply	[flat|nested] 6+ messages in thread
[parent not found: <<5d980f35-f43a-4968-8f59-d86acb06cca1@default>]
[parent not found: <<<5d980f35-f43a-4968-8f59-d86acb06cca1@default>]

end of thread, other threads:[~2017-07-28  7:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-18 21:33 bug#27424: 24.5; [PATCH] commands `apropos-local-variable', `apropos-local-value' Drew Adams
2017-07-22  8:01 ` Eli Zaretskii
     [not found] <<5d980f35-f43a-4968-8f59-d86acb06cca1@default>
     [not found] ` <<83d18saoi4.fsf@gnu.org>
2017-07-22 13:59   ` Drew Adams
2017-07-22 14:11     ` Eli Zaretskii
     [not found] <<<5d980f35-f43a-4968-8f59-d86acb06cca1@default>
     [not found] ` <<<83d18saoi4.fsf@gnu.org>
     [not found]   ` <<1610052b-f79c-485d-93e7-cc1d97961a26@default>
     [not found]     ` <<83o9sc8stc.fsf@gnu.org>
2017-07-22 23:29       ` Drew Adams
2017-07-28  7:49         ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).