all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: 27424@debbugs.gnu.org
Subject: bug#27424: 24.5; [PATCH] commands `apropos-local-variable', `apropos-local-value'
Date: Sun, 18 Jun 2017 14:33:46 -0700 (PDT)	[thread overview]
Message-ID: <5d980f35-f43a-4968-8f59-d86acb06cca1@default> (raw)

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

             reply	other threads:[~2017-06-18 21:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-18 21:33 Drew Adams [this message]
2017-07-22  8:01 ` bug#27424: 24.5; [PATCH] commands `apropos-local-variable', `apropos-local-value' 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5d980f35-f43a-4968-8f59-d86acb06cca1@default \
    --to=drew.adams@oracle.com \
    --cc=27424@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.