unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#48063: 28.0.50: apropos-value{, -internal}: suppress false positives
@ 2021-04-27 15:17 Boruch Baum
  2021-05-02  8:23 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 3+ messages in thread
From: Boruch Baum @ 2021-04-27 15:17 UTC (permalink / raw)
  To: 48063

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

Function apropos-value will always return false positive, some of which
entail printing out very long variable value strings. The attached patch
apropos-value.patch fixes those cases. The second patch just changes
what seems to be an indentation bug in the function.

The cases of false positives are:

+ variables reflecting the apropos request itself
  + (car minibuffer-history)
  + (car command-history)

+ variables internal to apropos:
  + apropos--current
  + apropos-pattern-quoted
  + pattern



--
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1  7286 0036 9E45 1595 8BC0

[-- Attachment #2: apropos-value.patch --]
[-- Type: text/x-diff, Size: 1022 bytes --]

diff --git a/apropos.el b/apropos.el
index 6d8c784..44c87ee 100644
--- a/apropos.el
+++ b/apropos.el
@@ -817,6 +817,7 @@ Returns list of symbols and values found."
       (lambda (symbol)
 	(setq f nil v nil p nil)
 	(or (memq symbol '(apropos-regexp
+                           apropos--current apropos-pattern-quoted pattern
 			   apropos-pattern apropos-all-words-regexp
 			   apropos-words apropos-all-words
 			   do-all apropos-accumulator
@@ -933,7 +934,10 @@ Returns list of symbols and documentation found."
 \f
 (defun apropos-value-internal (predicate symbol function)
   (when (funcall predicate symbol)
-    (setq symbol (prin1-to-string (funcall function symbol)))
+    (setq symbol (prin1-to-string
+      (if (memq symbol '(command-history minibuffer-history))
+        (cdr (funcall function symbol))
+       (funcall function symbol))))
     (when (string-match apropos-regexp symbol)
       (if apropos-match-face
           (put-text-property (match-beginning 0) (match-end 0)

[-- Attachment #3: apropos-value-indent-change.patch --]
[-- Type: text/x-diff, Size: 2579 bytes --]

diff --git a/apropos.el b/apropos.el
index 44c87ee..9529271 100644
--- a/apropos.el
+++ b/apropos.el
@@ -812,35 +812,35 @@ Returns list of symbols and values found."
   (apropos-parse-pattern pattern t)
   (or do-all (setq do-all apropos-do-all))
   (setq apropos-accumulator ())
-   (let (f v p)
-     (mapatoms
-      (lambda (symbol)
-	(setq f nil v nil p nil)
-	(or (memq symbol '(apropos-regexp
-                           apropos--current apropos-pattern-quoted pattern
-			   apropos-pattern apropos-all-words-regexp
-			   apropos-words apropos-all-words
-			   do-all apropos-accumulator
-			   symbol f v p))
-	    (setq v (apropos-value-internal 'boundp symbol 'symbol-value)))
-	(if do-all
-	    (setq f (apropos-value-internal 'fboundp symbol 'symbol-function)
-		  p (apropos-format-plist symbol "\n    " t)))
-	(if (apropos-false-hit-str v)
-	    (setq v nil))
-	(if (apropos-false-hit-str f)
-	    (setq f nil))
-	(if (apropos-false-hit-str p)
-	    (setq p nil))
-	(if (or f v p)
-	    (setq apropos-accumulator (cons (list symbol
-						  (+ (apropos-score-str f)
-						     (apropos-score-str v)
-						     (apropos-score-str p))
-						  f v p)
-					    apropos-accumulator))))))
-   (let ((apropos-multi-type do-all))
-     (apropos-print nil "\n----------------\n")))
+  (let (f v p)
+    (mapatoms
+     (lambda (symbol)
+       (setq f nil v nil p nil)
+       (or (memq symbol '(apropos-regexp
+                          apropos--current apropos-pattern-quoted pattern
+       		   apropos-pattern apropos-all-words-regexp
+       		   apropos-words apropos-all-words
+       		   do-all apropos-accumulator
+       		   symbol f v p))
+           (setq v (apropos-value-internal 'boundp symbol 'symbol-value)))
+       (if do-all
+           (setq f (apropos-value-internal 'fboundp symbol 'symbol-function)
+       	  p (apropos-format-plist symbol "\n    " t)))
+       (if (apropos-false-hit-str v)
+           (setq v nil))
+       (if (apropos-false-hit-str f)
+           (setq f nil))
+       (if (apropos-false-hit-str p)
+           (setq p nil))
+       (if (or f v p)
+           (setq apropos-accumulator (cons (list symbol
+       					  (+ (apropos-score-str f)
+       					     (apropos-score-str v)
+       					     (apropos-score-str p))
+       					  f v p)
+       				    apropos-accumulator))))))
+  (let ((apropos-multi-type do-all))
+    (apropos-print nil "\n----------------\n")))

 ;;;###autoload
 (defun apropos-local-value (pattern &optional buffer)

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* bug#48063: 28.0.50: apropos-value{, -internal}: suppress false positives
  2021-04-27 15:17 bug#48063: 28.0.50: apropos-value{, -internal}: suppress false positives Boruch Baum
@ 2021-05-02  8:23 ` Lars Ingebrigtsen
  2021-05-02 12:22   ` Boruch Baum
  0 siblings, 1 reply; 3+ messages in thread
From: Lars Ingebrigtsen @ 2021-05-02  8:23 UTC (permalink / raw)
  To: Boruch Baum; +Cc: 48063

Boruch Baum <boruch_baum@gmx.com> writes:

> Function apropos-value will always return false positive, some of which
> entail printing out very long variable value strings. The attached patch
> apropos-value.patch fixes those cases. The second patch just changes
> what seems to be an indentation bug in the function.

Thanks; applied to Emacs 28.  (This makes the command a lot more
useful -- these false positives have always annoyed me.)

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#48063: 28.0.50: apropos-value{, -internal}: suppress false positives
  2021-05-02  8:23 ` Lars Ingebrigtsen
@ 2021-05-02 12:22   ` Boruch Baum
  0 siblings, 0 replies; 3+ messages in thread
From: Boruch Baum @ 2021-05-02 12:22 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 48063

On 2021-05-02 10:23, Lars Ingebrigtsen wrote:
> Boruch Baum <boruch_baum@gmx.com> writes:
>
> > Function apropos-value will always return false positive, some of which
> > entail printing out very long variable value strings. The attached patch
> > apropos-value.patch fixes those cases. The second patch just changes
> > what seems to be an indentation bug in the function.
>
> Thanks; applied to Emacs 28.  (This makes the command a lot more
> useful -- these false positives have always annoyed me.)

Great!

--
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1  7286 0036 9E45 1595 8BC0





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-05-02 12:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-27 15:17 bug#48063: 28.0.50: apropos-value{, -internal}: suppress false positives Boruch Baum
2021-05-02  8:23 ` Lars Ingebrigtsen
2021-05-02 12:22   ` Boruch Baum

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