From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Boruch Baum Newsgroups: gmane.emacs.bugs Subject: bug#31094: Code for second solution Date: Sun, 8 Apr 2018 07:09:01 -0400 Message-ID: <20180408110901.4dukaueroieovrkp@E15-2016.optimum.net> References: <20180408073916.d5lsceul3gpj34l3@E15-2016.optimum.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="v2vwy2qwgalrblb4" X-Trace: blaine.gmane.org 1523185695 19915 195.159.176.226 (8 Apr 2018 11:08:15 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 8 Apr 2018 11:08:15 +0000 (UTC) User-Agent: NeoMutt/20180223 To: 31094@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Apr 08 13:08:11 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1f58B6-00052d-W8 for geb-bug-gnu-emacs@m.gmane.org; Sun, 08 Apr 2018 13:08:09 +0200 Original-Received: from localhost ([::1]:46500 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f58DA-0005gZ-My for geb-bug-gnu-emacs@m.gmane.org; Sun, 08 Apr 2018 07:10:16 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38674) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f58D2-0005fv-1Q for bug-gnu-emacs@gnu.org; Sun, 08 Apr 2018 07:10:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f58Cx-0007xM-16 for bug-gnu-emacs@gnu.org; Sun, 08 Apr 2018 07:10:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:34044) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f58Cw-0007wk-RV for bug-gnu-emacs@gnu.org; Sun, 08 Apr 2018 07:10:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1f58Cv-00058Y-Qx for bug-gnu-emacs@gnu.org; Sun, 08 Apr 2018 07:10:02 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: <20180408073916.d5lsceul3gpj34l3@E15-2016.optimum.net> Resent-From: Boruch Baum Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 08 Apr 2018 11:10:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 31094 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 31094-submit@debbugs.gnu.org id=B31094.152318575319686 (code B ref 31094); Sun, 08 Apr 2018 11:10:01 +0000 Original-Received: (at 31094) by debbugs.gnu.org; 8 Apr 2018 11:09:13 +0000 Original-Received: from localhost ([127.0.0.1]:41941 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1f58C8-00057S-Hk for submit@debbugs.gnu.org; Sun, 08 Apr 2018 07:09:12 -0400 Original-Received: from mout.gmx.net ([212.227.17.20]:60071) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1f58C7-00057F-2k for 31094@debbugs.gnu.org; Sun, 08 Apr 2018 07:09:11 -0400 Original-Received: from E15-2016.optimum.net ([108.6.168.221]) by mail.gmx.com (mrgmx102 [212.227.17.174]) with ESMTPSA (Nemesis) id 0M1RHp-1eBe8133mr-00tU6l for <31094@debbugs.gnu.org>; Sun, 08 Apr 2018 13:09:05 +0200 Content-Disposition: inline X-Provags-ID: V03:K1:Kzwcp2MUEofV3hMwQWC7spzRt8YVTxqJWqlHLwI33yqOPCLfEge CXS/TiALmVrbODhaT8I+tPAWZBPecDCNayshHs8b31Q81jnAtK4xuNQGdiJbd2og/m2oKt6 Vba3NOhTx2HY0tSJQSVyrgvJjDPelnkYie3ChmCtqfnHFDaZEBXytOpw7KGb+EUdvTtXkmq AheMqB1yjk90pVNXchUNw== X-UI-Out-Filterresults: notjunk:1;V01:K0:6E4e8F4LkWo=:sWDkEBVUQ5wNbR0403fm7J a4EWXFPGBBY31uB9pDV1xYEGjaIkwkGOUpKG8WS2eyNGso43X3FNpWr5zBu5knZALKXignZX+ 9s1B7gqlFJZTCVAquSgPWORWd8OSz5ovoO/8YrGpjt04ghYHErvIsFJ0dXOufvjzuM+oDnd8R NWjj3w2/wIqC+LX9Azd7LdW/jHeeMhCKIbdBjdnudN5sYm+L8CvzCkuFoczSCRxxrP+zBt3Dc xiqQ8rEu/9C5bAscsu5+RA7AXzjA1sqbuaPjgNcgbZ3RNKT2oYxFfRQBFPAPqxvakcxxt1j9m 2lxxQeuzwRz0ZiXNOHyPXlQxlaIiYKV9UfggqG6uEk58kUDDgofDidjH/ccEXkxH74K1o1ttZ REwlqJhBM3ouY0o9vsug/tPv7qz900aNTozG9H98ufNSiMXDXbDM9O6ZQpath9gM78RRCtTOD x/a5Myw/hCvMFraQPUvJ6REtOSiVZY3fxvbHX5QHXylKdaqxBxIZDKCkdMdZSKLGuEMPuYBBM nK8ZXIo8dV3YjfeU80aZ6VQYTbBiwaUnPZGBIrxZ61538gxbNOszWsGfoAKK1fh4XRRYeiD0s 9pZ62Flb8ohZxJKfnHzlM70rX+qJ2nPa3mWtMcndrV3dNzAxGzb5D9GFvJoQ51XQbUhFO8Qki jgSnvMDMOzI1ZDhYhNeafkWHQp0rgUw92H90ZQzqy2nixHImbfyXTQUQEJy+HtU3flpvO0hLz JlP4Y5bj4TbH04WMUeMS4+Ae99lT6JU4imhO+fDs42sVN7mol5dSn2mvASHjBVDfr3ncN6lC X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:144992 Archived-At: --v2vwy2qwgalrblb4 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Attached is code for the second solution idea that I mrentioned in my first post. Note that these approaches are complementary and independent; I would advocate for both being adopted. Do note that this 'breaks' a feature formerly available. Prior, pressing return on an entry would display documentation for that entry; Now one must press `C-h v' / `C-h f' etc. -- hkp://keys.gnupg.net CA45 09B5 5351 7C11 A9D1 7286 0036 9E45 1595 8BC0 --v2vwy2qwgalrblb4 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="apropos-print.el" (defcustom apropos-value-limited-print nil "Print only symbol names, not their contents. When this option is active, one may always view a symbol's contents by `C-h v' while point is on the symbol's name." :type 'boolean) (defun apropos-print (do-keys spacing &optional text nosubst) "Output result of apropos searching into buffer `*Apropos*'. The value of `apropos-accumulator' is the list of items to output. Each element should have the format (SYMBOL SCORE FN-DOC VAR-DOC [PLIST-DOC WIDGET-DOC FACE-DOC GROUP-DOC]). The return value is the list that was in `apropos-accumulator', sorted alphabetically by symbol name; but this function also sets `apropos-accumulator' to nil before returning. If DO-KEYS is non-nil, output the key bindings. If NOSUBST is nil, substitute \"ASCII quotes\" (i.e., grace accent and apostrophe) with curly quotes), and if non-nil, leave them alone. If SPACING is non-nil, it should be a string; separate items with that string. If non-nil, TEXT is a string that will be printed as a heading." (if (null apropos-accumulator) (message "No apropos matches for `%s'" apropos-pattern) (setq apropos-accumulator (sort apropos-accumulator (lambda (a b) (if apropos-sort-by-scores (or (> (cadr a) (cadr b)) (and (= (cadr a) (cadr b)) (string-lessp (car a) (car b)))) (string-lessp (car a) (car b)))))) (with-output-to-temp-buffer "*Apropos*" (let ((p apropos-accumulator) (old-buffer (current-buffer)) (inhibit-read-only t) (button-end 0) symbol item) (set-buffer standard-output) (apropos-mode) (if text (insert text "\n\n")) (dolist (apropos-item p) (when (and (not apropos-value-limited-print) spacing (not (bobp))) (princ spacing)) (setq symbol (car apropos-item)) ;; Insert dummy score element for backwards compatibility with 21.x ;; apropos-item format. (if (not (numberp (cadr apropos-item))) (setq apropos-item (cons (car apropos-item) (cons nil (cdr apropos-item))))) (when (= (point) button-end) (terpri)) (insert-text-button (symbol-name symbol) 'type 'apropos-symbol 'skip apropos-multi-type 'face 'apropos-symbol) (setq button-end (point)) (if (and (eq apropos-sort-by-scores 'verbose) (cadr apropos-item)) (insert " (" (number-to-string (cadr apropos-item)) ") ")) ;; Calculate key-bindings if we want them. (unless apropos-compact-layout (and do-keys (commandp symbol) (not (eq symbol 'self-insert-command)) (indent-to 30 1) (if (let ((keys (with-current-buffer old-buffer (where-is-internal symbol))) filtered) ;; Copy over the list of key sequences, ;; omitting any that contain a buffer or a frame. ;; FIXME: Why omit keys that contain buffers and ;; frames? This looks like a bad workaround rather ;; than a proper fix. Does anybody know what problem ;; this is trying to address? --Stef (dolist (key keys) (let ((i 0) loser) (while (< i (length key)) (if (or (framep (aref key i)) (bufferp (aref key i))) (setq loser t)) (setq i (1+ i))) (or loser (push key filtered)))) (setq item filtered)) ;; Convert the remaining keys to a string and insert. (insert (mapconcat (lambda (key) (setq key (condition-case () (key-description key) (error))) (put-text-property 0 (length key) 'face 'apropos-keybinding key) key) item ", ")) (insert "M-x ... RET") (put-text-property (- (point) 11) (- (point) 8) 'face 'apropos-keybinding) (put-text-property (- (point) 3) (point) 'face 'apropos-keybinding))) (terpri)) (when (not apropos-value-limited-print) (apropos-print-doc 2 (if (commandp symbol) 'apropos-command (if (macrop symbol) 'apropos-macro 'apropos-function)) (not nosubst)) (apropos-print-doc 3 (if (custom-variable-p symbol) 'apropos-user-option 'apropos-variable) (not nosubst)) (apropos-print-doc 7 'apropos-group t) (apropos-print-doc 6 'apropos-face t) (apropos-print-doc 5 'apropos-widget t) (apropos-print-doc 4 'apropos-plist nil))) (set (make-local-variable 'truncate-partial-width-windows) t) (set (make-local-variable 'truncate-lines) t)))) (prog1 apropos-accumulator (setq apropos-accumulator ()))) ; permit gc --v2vwy2qwgalrblb4--