diff options
| -rw-r--r-- | lisp/ChangeLog | 12 | ||||
| -rw-r--r-- | lisp/apropos.el | 123 |
2 files changed, 89 insertions, 46 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index af58ef47b28..4b8389877a2 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,15 @@ | |||
| 1 | 2011-04-24 Chong Yidong <cyd@stupidchicken.com> | ||
| 2 | |||
| 3 | * apropos.el (apropos-label-face): Avoid variable-pitch face. | ||
| 4 | (apropos-accumulator): Doc fix. | ||
| 5 | (apropos-function, apropos-macro, apropos-command) | ||
| 6 | (apropos-variable, apropos-face, apropos-group, apropos-widget) | ||
| 7 | (apropos-plist): Add face property. | ||
| 8 | (apropos-symbols-internal): Fix indentation. | ||
| 9 | (apropos-print): Simplify help, and recognize apropos-multi-type. | ||
| 10 | (apropos-print-doc): Use button-type-get to extract the button's | ||
| 11 | face property. Fill docstring (Bug#8352). | ||
| 12 | |||
| 1 | 2011-04-23 Juanma Barranquero <lekktu@gmail.com> | 13 | 2011-04-23 Juanma Barranquero <lekktu@gmail.com> |
| 2 | 14 | ||
| 3 | * buff-menu.el (Buffer-menu--buffers): Fix typo in docstring (bug#8535). | 15 | * buff-menu.el (Buffer-menu--buffers): Fix typo in docstring (bug#8535). |
diff --git a/lisp/apropos.el b/lisp/apropos.el index 35a3ac3c09a..f1baee8dafe 100644 --- a/lisp/apropos.el +++ b/lisp/apropos.el | |||
| @@ -83,7 +83,7 @@ Slows them down more or less. Set this non-nil if you have a fast machine." | |||
| 83 | :group 'apropos | 83 | :group 'apropos |
| 84 | :type 'face) | 84 | :type 'face) |
| 85 | 85 | ||
| 86 | (defcustom apropos-label-face '(italic variable-pitch) | 86 | (defcustom apropos-label-face '(italic) |
| 87 | "Face for label (`Command', `Variable' ...) in Apropos output. | 87 | "Face for label (`Command', `Variable' ...) in Apropos output. |
| 88 | A value of nil means don't use any special font for them, and also | 88 | A value of nil means don't use any special font for them, and also |
| 89 | turns off mouse highlighting." | 89 | turns off mouse highlighting." |
| @@ -155,7 +155,17 @@ If value is `verbose', the computed score is shown for each match." | |||
| 155 | "List of elc files already scanned in current run of `apropos-documentation'.") | 155 | "List of elc files already scanned in current run of `apropos-documentation'.") |
| 156 | 156 | ||
| 157 | (defvar apropos-accumulator () | 157 | (defvar apropos-accumulator () |
| 158 | "Alist of symbols already found in current apropos run.") | 158 | "Alist of symbols already found in current apropos run. |
| 159 | Each element has the form | ||
| 160 | |||
| 161 | (SYMBOL SCORE FUN-DOC VAR-DOC PLIST WIDGET-DOC FACE-DOC CUS-GROUP-DOC) | ||
| 162 | |||
| 163 | where SYMBOL is the symbol name, SCORE is its relevance score (a | ||
| 164 | number), FUN-DOC is the function docstring, VAR-DOC is the | ||
| 165 | variable docstring, PLIST is the list of the symbols names in the | ||
| 166 | property list, WIDGET-DOC is the widget docstring, FACE-DOC is | ||
| 167 | the face docstring, and CUS-GROUP-DOC is the custom group | ||
| 168 | docstring. Each docstring is either nil or a string.") | ||
| 159 | 169 | ||
| 160 | (defvar apropos-item () | 170 | (defvar apropos-item () |
| 161 | "Current item in or for `apropos-accumulator'.") | 171 | "Current item in or for `apropos-accumulator'.") |
| @@ -187,6 +197,7 @@ term, and the rest of the words are alternative terms.") | |||
| 187 | (define-button-type 'apropos-function | 197 | (define-button-type 'apropos-function |
| 188 | 'apropos-label "Function" | 198 | 'apropos-label "Function" |
| 189 | 'apropos-short-label "f" | 199 | 'apropos-short-label "f" |
| 200 | 'face '(font-lock-function-name-face button) | ||
| 190 | 'help-echo "mouse-2, RET: Display more help on this function" | 201 | 'help-echo "mouse-2, RET: Display more help on this function" |
| 191 | 'follow-link t | 202 | 'follow-link t |
| 192 | 'action (lambda (button) | 203 | 'action (lambda (button) |
| @@ -195,6 +206,7 @@ term, and the rest of the words are alternative terms.") | |||
| 195 | (define-button-type 'apropos-macro | 206 | (define-button-type 'apropos-macro |
| 196 | 'apropos-label "Macro" | 207 | 'apropos-label "Macro" |
| 197 | 'apropos-short-label "m" | 208 | 'apropos-short-label "m" |
| 209 | 'face '(font-lock-function-name-face button) | ||
| 198 | 'help-echo "mouse-2, RET: Display more help on this macro" | 210 | 'help-echo "mouse-2, RET: Display more help on this macro" |
| 199 | 'follow-link t | 211 | 'follow-link t |
| 200 | 'action (lambda (button) | 212 | 'action (lambda (button) |
| @@ -203,6 +215,7 @@ term, and the rest of the words are alternative terms.") | |||
| 203 | (define-button-type 'apropos-command | 215 | (define-button-type 'apropos-command |
| 204 | 'apropos-label "Command" | 216 | 'apropos-label "Command" |
| 205 | 'apropos-short-label "c" | 217 | 'apropos-short-label "c" |
| 218 | 'face '(font-lock-function-name-face button) | ||
| 206 | 'help-echo "mouse-2, RET: Display more help on this command" | 219 | 'help-echo "mouse-2, RET: Display more help on this command" |
| 207 | 'follow-link t | 220 | 'follow-link t |
| 208 | 'action (lambda (button) | 221 | 'action (lambda (button) |
| @@ -216,6 +229,7 @@ term, and the rest of the words are alternative terms.") | |||
| 216 | (define-button-type 'apropos-variable | 229 | (define-button-type 'apropos-variable |
| 217 | 'apropos-label "Variable" | 230 | 'apropos-label "Variable" |
| 218 | 'apropos-short-label "v" | 231 | 'apropos-short-label "v" |
| 232 | 'face '(font-lock-variable-name-face button) | ||
| 219 | 'help-echo "mouse-2, RET: Display more help on this variable" | 233 | 'help-echo "mouse-2, RET: Display more help on this variable" |
| 220 | 'follow-link t | 234 | 'follow-link t |
| 221 | 'action (lambda (button) | 235 | 'action (lambda (button) |
| @@ -224,6 +238,7 @@ term, and the rest of the words are alternative terms.") | |||
| 224 | (define-button-type 'apropos-face | 238 | (define-button-type 'apropos-face |
| 225 | 'apropos-label "Face" | 239 | 'apropos-label "Face" |
| 226 | 'apropos-short-label "F" | 240 | 'apropos-short-label "F" |
| 241 | 'face '(font-lock-variable-name-face button) | ||
| 227 | 'help-echo "mouse-2, RET: Display more help on this face" | 242 | 'help-echo "mouse-2, RET: Display more help on this face" |
| 228 | 'follow-link t | 243 | 'follow-link t |
| 229 | 'action (lambda (button) | 244 | 'action (lambda (button) |
| @@ -232,6 +247,7 @@ term, and the rest of the words are alternative terms.") | |||
| 232 | (define-button-type 'apropos-group | 247 | (define-button-type 'apropos-group |
| 233 | 'apropos-label "Group" | 248 | 'apropos-label "Group" |
| 234 | 'apropos-short-label "g" | 249 | 'apropos-short-label "g" |
| 250 | 'face '(font-lock-builtin-face button) | ||
| 235 | 'help-echo "mouse-2, RET: Display more help on this group" | 251 | 'help-echo "mouse-2, RET: Display more help on this group" |
| 236 | 'follow-link t | 252 | 'follow-link t |
| 237 | 'action (lambda (button) | 253 | 'action (lambda (button) |
| @@ -241,14 +257,16 @@ term, and the rest of the words are alternative terms.") | |||
| 241 | (define-button-type 'apropos-widget | 257 | (define-button-type 'apropos-widget |
| 242 | 'apropos-label "Widget" | 258 | 'apropos-label "Widget" |
| 243 | 'apropos-short-label "w" | 259 | 'apropos-short-label "w" |
| 260 | 'face '(font-lock-builtin-face button) | ||
| 244 | 'help-echo "mouse-2, RET: Display more help on this widget" | 261 | 'help-echo "mouse-2, RET: Display more help on this widget" |
| 245 | 'follow-link t | 262 | 'follow-link t |
| 246 | 'action (lambda (button) | 263 | 'action (lambda (button) |
| 247 | (widget-browse-other-window (button-get button 'apropos-symbol)))) | 264 | (widget-browse-other-window (button-get button 'apropos-symbol)))) |
| 248 | 265 | ||
| 249 | (define-button-type 'apropos-plist | 266 | (define-button-type 'apropos-plist |
| 250 | 'apropos-label "Plist" | 267 | 'apropos-label "Properties" |
| 251 | 'apropos-short-label "p" | 268 | 'apropos-short-label "p" |
| 269 | 'face '(font-lock-keyword-face button) | ||
| 252 | 'help-echo "mouse-2, RET: Display more help on this plist" | 270 | 'help-echo "mouse-2, RET: Display more help on this plist" |
| 253 | 'follow-link t | 271 | 'follow-link t |
| 254 | 'action (lambda (button) | 272 | 'action (lambda (button) |
| @@ -636,15 +654,15 @@ thus be found in `load-history'." | |||
| 636 | "(not documented)")) | 654 | "(not documented)")) |
| 637 | (when (boundp symbol) | 655 | (when (boundp symbol) |
| 638 | (apropos-documentation-property | 656 | (apropos-documentation-property |
| 639 | symbol 'variable-documentation t)) | 657 | symbol 'variable-documentation t)) |
| 640 | (when (setq properties (symbol-plist symbol)) | 658 | (when (setq properties (symbol-plist symbol)) |
| 641 | (setq doc (list (car properties))) | 659 | (setq doc (list (car properties))) |
| 642 | (while (setq properties (cdr (cdr properties))) | 660 | (while (setq properties (cdr (cdr properties))) |
| 643 | (setq doc (cons (car properties) doc))) | 661 | (setq doc (cons (car properties) doc))) |
| 644 | (mapconcat #'symbol-name (nreverse doc) " ")) | 662 | (mapconcat #'symbol-name (nreverse doc) " ")) |
| 645 | (when (get symbol 'widget-type) | 663 | (when (get symbol 'widget-type) |
| 646 | (apropos-documentation-property | 664 | (apropos-documentation-property |
| 647 | symbol 'widget-documentation t)) | 665 | symbol 'widget-documentation t)) |
| 648 | (when (facep symbol) | 666 | (when (facep symbol) |
| 649 | (let ((alias (get symbol 'face-alias))) | 667 | (let ((alias (get symbol 'face-alias))) |
| 650 | (if alias | 668 | (if alias |
| @@ -660,8 +678,8 @@ thus be found in `load-history'." | |||
| 660 | (apropos-documentation-property | 678 | (apropos-documentation-property |
| 661 | symbol 'face-documentation t)))) | 679 | symbol 'face-documentation t)))) |
| 662 | (when (get symbol 'custom-group) | 680 | (when (get symbol 'custom-group) |
| 663 | (apropos-documentation-property | 681 | (apropos-documentation-property |
| 664 | symbol 'group-documentation t))))) | 682 | symbol 'group-documentation t))))) |
| 665 | symbols))) | 683 | symbols))) |
| 666 | (apropos-print keys nil text))) | 684 | (apropos-print keys nil text))) |
| 667 | 685 | ||
| @@ -976,15 +994,9 @@ If non-nil TEXT is a string that will be printed as a heading." | |||
| 976 | symbol item) | 994 | symbol item) |
| 977 | (set-buffer standard-output) | 995 | (set-buffer standard-output) |
| 978 | (apropos-mode) | 996 | (apropos-mode) |
| 979 | (if (display-mouse-p) | 997 | (insert (substitute-command-keys "Type \\[apropos-follow] on ") |
| 980 | (insert | 998 | (if apropos-multi-type "a type label" "an entry") |
| 981 | "If moving the mouse over text changes the text's color, " | 999 | " to view its full documentation.\n\n") |
| 982 | "you can click\n" | ||
| 983 | "or press return on that text to get more information.\n")) | ||
| 984 | (insert "In this buffer, go to the name of the command, or function," | ||
| 985 | " or variable,\n" | ||
| 986 | (substitute-command-keys | ||
| 987 | "and type \\[apropos-follow] to get full documentation.\n\n")) | ||
| 988 | (if text (insert text "\n\n")) | 1000 | (if text (insert text "\n\n")) |
| 989 | (dolist (apropos-item p) | 1001 | (dolist (apropos-item p) |
| 990 | (when (and spacing (not (bobp))) | 1002 | (when (and spacing (not (bobp))) |
| @@ -1082,30 +1094,49 @@ If non-nil TEXT is a string that will be printed as a heading." | |||
| 1082 | 1094 | ||
| 1083 | 1095 | ||
| 1084 | (defun apropos-print-doc (i type do-keys) | 1096 | (defun apropos-print-doc (i type do-keys) |
| 1085 | (when (stringp (setq i (nth i apropos-item))) | 1097 | (let ((doc (nth i apropos-item))) |
| 1086 | (if apropos-compact-layout | 1098 | (when (stringp doc) |
| 1087 | (insert (propertize "\t" 'display '(space :align-to 32)) " ") | 1099 | (if apropos-compact-layout |
| 1088 | (insert " ")) | 1100 | (insert (propertize "\t" 'display '(space :align-to 32)) " ") |
| 1089 | (if (null apropos-multi-type) | 1101 | (insert " ")) |
| 1090 | ;; If the query is only for a single type, there's no point | 1102 | (if apropos-multi-type |
| 1091 | ;; writing it over and over again. Insert a blank button, and | 1103 | (let ((button-face (button-type-get type 'face))) |
| 1092 | ;; put the 'apropos-label property there (needed by | 1104 | (unless (consp button-face) |
| 1093 | ;; apropos-symbol-button-display-help). | 1105 | (setq button-face (list button-face))) |
| 1094 | (insert-text-button | 1106 | (insert-text-button |
| 1107 | (if apropos-compact-layout | ||
| 1108 | (format "<%s>" (button-type-get type 'apropos-short-label)) | ||
| 1109 | (button-type-get type 'apropos-label)) | ||
| 1110 | 'type type | ||
| 1111 | ;; Can't use the default button face, since user may have changed the | ||
| 1112 | ;; variable! Just say `no' to variables containing faces! | ||
| 1113 | 'face (append button-face apropos-label-face) | ||
| 1114 | 'apropos-symbol (car apropos-item)) | ||
| 1115 | (insert (if apropos-compact-layout " " ": "))) | ||
| 1116 | |||
| 1117 | ;; If the query is only for a single type, there's no point | ||
| 1118 | ;; writing it over and over again. Insert a blank button, and | ||
| 1119 | ;; put the 'apropos-label property there (needed by | ||
| 1120 | ;; apropos-symbol-button-display-help). | ||
| 1121 | (insert-text-button | ||
| 1095 | " " 'type type 'skip t | 1122 | " " 'type type 'skip t |
| 1096 | 'face 'default 'apropos-symbol (car apropos-item)) | 1123 | 'face 'default 'apropos-symbol (car apropos-item))) |
| 1097 | (insert-text-button | 1124 | |
| 1098 | (if apropos-compact-layout | 1125 | (let ((opoint (point)) |
| 1099 | (format "<%s>" (button-type-get type 'apropos-short-label)) | 1126 | (ocol (current-column))) |
| 1100 | (button-type-get type 'apropos-label)) | 1127 | (cond ((equal doc "") |
| 1101 | 'type type | 1128 | (setq doc "(not documented)")) |
| 1102 | ;; Can't use the default button face, since user may have changed the | 1129 | (do-keys |
| 1103 | ;; variable! Just say `no' to variables containing faces! | 1130 | (setq doc (substitute-command-keys doc)))) |
| 1104 | 'face apropos-label-face | 1131 | (insert doc) |
| 1105 | 'apropos-symbol (car apropos-item)) | 1132 | (if (equal doc "(not documented)") |
| 1106 | (insert (if apropos-compact-layout " " ": "))) | 1133 | (put-text-property opoint (point) 'font-lock-face 'shadow)) |
| 1107 | (insert (if do-keys (substitute-command-keys i) i)) | 1134 | ;; The labeling buttons might make the line too long, so fill it if |
| 1108 | (or (bolp) (terpri)))) | 1135 | ;; necessary. |
| 1136 | (let ((fill-column (+ 5 emacs-lisp-docstring-fill-column)) | ||
| 1137 | (fill-prefix (make-string ocol ?\s))) | ||
| 1138 | (fill-region opoint (point) nil t))) | ||
| 1139 | (or (bolp) (terpri))))) | ||
| 1109 | 1140 | ||
| 1110 | (defun apropos-follow () | 1141 | (defun apropos-follow () |
| 1111 | "Invokes any button at point, otherwise invokes the nearest label button." | 1142 | "Invokes any button at point, otherwise invokes the nearest label button." |