aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2008-06-10 02:44:48 +0000
committerStefan Monnier2008-06-10 02:44:48 +0000
commit1d69bd9baabc358cf979aa92fd9f1e6072a0fbf3 (patch)
tree3f5b4e92408f9d58053a0265f2bb64ef7ecb2745
parent9552dbd17d9c4c4f701e5f4b6155023dbf061cd0 (diff)
downloademacs-1d69bd9baabc358cf979aa92fd9f1e6072a0fbf3.tar.gz
emacs-1d69bd9baabc358cf979aa92fd9f1e6072a0fbf3.zip
(apropos-function, apropos-macro, apropos-command)
(apropos-variable, apropos-face, apropos-group, apropos-widget) (apropos-plist): Add apropos-short-label property. (apropos-multi-type): New variables. (apropos-command, apropos-value): Set it. (apropos-compact-layout): New custom. (apropos-print, apropos-print-doc): Use it. (apropos-print): Truncate lines.
-rw-r--r--etc/NEWS4
-rw-r--r--lisp/ChangeLog17
-rw-r--r--lisp/apropos.el142
3 files changed, 101 insertions, 62 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 9808e043e74..7b24a232f2d 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -63,7 +63,9 @@ default toolkit, but you can use --with-x-toolkit=gtk if necessary.
63 63
64* Changes in Emacs 23.1 64* Changes in Emacs 23.1
65 65
66** `apropos-library' describes the elements defined in a given library. 66** Apropos
67*** `apropos-library' describes the elements defined in a given library.
68*** Set `apropos-compact-layout' is you want a more compact (but wider) layout.
67 69
68** scroll-preserve-screen-position also preserves the column position. 70** scroll-preserve-screen-position also preserves the column position.
69** Completion. 71** Completion.
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 81196b7ec2c..b1299d78b8e 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,14 @@
12008-06-10 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * apropos.el (apropos-function, apropos-macro, apropos-command)
4 (apropos-variable, apropos-face, apropos-group, apropos-widget)
5 (apropos-plist): Add apropos-short-label property.
6 (apropos-multi-type): New variables.
7 (apropos-command, apropos-value): Set it.
8 (apropos-compact-layout): New custom.
9 (apropos-print, apropos-print-doc): Use it.
10 (apropos-print): Truncate lines.
11
12008-06-09 Kenichi Handa <handa@m17n.org> 122008-06-09 Kenichi Handa <handa@m17n.org>
2 13
3 * international/fontset.el (font-encoding-alist): 14 * international/fontset.el (font-encoding-alist):
@@ -149,7 +160,7 @@
149 to `newsticker--plainview-tool-bar-map'. 160 to `newsticker--plainview-tool-bar-map'.
150 (newsticker--url-keymap): Add mouse-1 binding. 161 (newsticker--url-keymap): Add mouse-1 binding.
151 (newsticker-plainview): New. 162 (newsticker-plainview): New.
152 (newsticker-mark-all-items-of-feed-as-read): Doc changed. 163 (newsticker-mark-all-items-of-feed-as-read): Change doc.
153 (newsticker--buffer-do-insert-text): Use renamed 164 (newsticker--buffer-do-insert-text): Use renamed
154 newsticker--[buffer-]insert-enclosure and 165 newsticker--[buffer-]insert-enclosure and
155 newsticker--[buffer-]print-extra-elements. 166 newsticker--[buffer-]print-extra-elements.
@@ -173,8 +184,8 @@
173 * window.el (split-height-threshold, split-width-threshold): 184 * window.el (split-height-threshold, split-width-threshold):
174 Add choice nil. 185 Add choice nil.
175 (split-window-preferred-function): Allow either nil or a function. 186 (split-window-preferred-function): Allow either nil or a function.
176 (window--splittable-p, window--try-to-split-window): Handle 187 (window--splittable-p, window--try-to-split-window):
177 changed option values. 188 Handle changed option values.
178 189
179 (window--frame-usable-p): Handle nil argument. 190 (window--frame-usable-p): Handle nil argument.
180 191
diff --git a/lisp/apropos.el b/lisp/apropos.el
index d453cb89de8..a56cd4218e3 100644
--- a/lisp/apropos.el
+++ b/lisp/apropos.el
@@ -190,6 +190,7 @@ term, and the rest of the words are alternative terms.")
190 190
191(define-button-type 'apropos-function 191(define-button-type 'apropos-function
192 'apropos-label "Function" 192 'apropos-label "Function"
193 'apropos-short-label "f"
193 'help-echo "mouse-2, RET: Display more help on this function" 194 'help-echo "mouse-2, RET: Display more help on this function"
194 'follow-link t 195 'follow-link t
195 'action (lambda (button) 196 'action (lambda (button)
@@ -197,6 +198,7 @@ term, and the rest of the words are alternative terms.")
197 198
198(define-button-type 'apropos-macro 199(define-button-type 'apropos-macro
199 'apropos-label "Macro" 200 'apropos-label "Macro"
201 'apropos-short-label "m"
200 'help-echo "mouse-2, RET: Display more help on this macro" 202 'help-echo "mouse-2, RET: Display more help on this macro"
201 'follow-link t 203 'follow-link t
202 'action (lambda (button) 204 'action (lambda (button)
@@ -204,6 +206,7 @@ term, and the rest of the words are alternative terms.")
204 206
205(define-button-type 'apropos-command 207(define-button-type 'apropos-command
206 'apropos-label "Command" 208 'apropos-label "Command"
209 'apropos-short-label "c"
207 'help-echo "mouse-2, RET: Display more help on this command" 210 'help-echo "mouse-2, RET: Display more help on this command"
208 'follow-link t 211 'follow-link t
209 'action (lambda (button) 212 'action (lambda (button)
@@ -216,6 +219,7 @@ term, and the rest of the words are alternative terms.")
216;; Likewise for `customize-face-other-window'. 219;; Likewise for `customize-face-other-window'.
217(define-button-type 'apropos-variable 220(define-button-type 'apropos-variable
218 'apropos-label "Variable" 221 'apropos-label "Variable"
222 'apropos-short-label "v"
219 'help-echo "mouse-2, RET: Display more help on this variable" 223 'help-echo "mouse-2, RET: Display more help on this variable"
220 'follow-link t 224 'follow-link t
221 'action (lambda (button) 225 'action (lambda (button)
@@ -223,6 +227,7 @@ term, and the rest of the words are alternative terms.")
223 227
224(define-button-type 'apropos-face 228(define-button-type 'apropos-face
225 'apropos-label "Face" 229 'apropos-label "Face"
230 'apropos-short-label "F"
226 'help-echo "mouse-2, RET: Display more help on this face" 231 'help-echo "mouse-2, RET: Display more help on this face"
227 'follow-link t 232 'follow-link t
228 'action (lambda (button) 233 'action (lambda (button)
@@ -230,6 +235,7 @@ term, and the rest of the words are alternative terms.")
230 235
231(define-button-type 'apropos-group 236(define-button-type 'apropos-group
232 'apropos-label "Group" 237 'apropos-label "Group"
238 'apropos-short-label "g"
233 'help-echo "mouse-2, RET: Display more help on this group" 239 'help-echo "mouse-2, RET: Display more help on this group"
234 'follow-link t 240 'follow-link t
235 'action (lambda (button) 241 'action (lambda (button)
@@ -238,6 +244,7 @@ term, and the rest of the words are alternative terms.")
238 244
239(define-button-type 'apropos-widget 245(define-button-type 'apropos-widget
240 'apropos-label "Widget" 246 'apropos-label "Widget"
247 'apropos-short-label "w"
241 'help-echo "mouse-2, RET: Display more help on this widget" 248 'help-echo "mouse-2, RET: Display more help on this widget"
242 'follow-link t 249 'follow-link t
243 'action (lambda (button) 250 'action (lambda (button)
@@ -245,6 +252,7 @@ term, and the rest of the words are alternative terms.")
245 252
246(define-button-type 'apropos-plist 253(define-button-type 'apropos-plist
247 'apropos-label "Plist" 254 'apropos-label "Plist"
255 'apropos-short-label "p"
248 'help-echo "mouse-2, RET: Display more help on this plist" 256 'help-echo "mouse-2, RET: Display more help on this plist"
249 'follow-link t 257 'follow-link t
250 'action (lambda (button) 258 'action (lambda (button)
@@ -408,6 +416,10 @@ This requires that at least 2 keywords (unless only one was given)."
408 416
409\\{apropos-mode-map}") 417\\{apropos-mode-map}")
410 418
419(defvar apropos-multi-type t
420 "If non-nil, this apropos query concerns multiple types.
421This is used to decide whether to print the result's type or not.")
422
411;;;###autoload 423;;;###autoload
412(defun apropos-variable (pattern &optional do-all) 424(defun apropos-variable (pattern &optional do-all)
413 "Show user variables that match PATTERN. 425 "Show user variables that match PATTERN.
@@ -493,7 +505,8 @@ while a list of strings is used as a word list."
493 (string-match "\n" doc))))))) 505 (string-match "\n" doc)))))))
494 (setcar (cdr (car p)) score) 506 (setcar (cdr (car p)) score)
495 (setq p (cdr p)))) 507 (setq p (cdr p))))
496 (and (apropos-print t nil nil t) 508 (and (let ((apropos-multi-type do-all))
509 (apropos-print t nil nil t))
497 message 510 message
498 (message "%s" message)))) 511 (message "%s" message))))
499 512
@@ -683,7 +696,8 @@ Returns list of symbols and values found."
683 (apropos-score-str p)) 696 (apropos-score-str p))
684 f v p) 697 f v p)
685 apropos-accumulator)))))) 698 apropos-accumulator))))))
686 (apropos-print nil "\n----------------\n")) 699 (let ((apropos-multi-type do-all))
700 (apropos-print nil "\n----------------\n")))
687 701
688 702
689;;;###autoload 703;;;###autoload
@@ -910,6 +924,9 @@ Will return nil instead."
910 nil 924 nil
911 function)) 925 function))
912 926
927(defcustom apropos-compact-layout nil
928 "If non-nil, use a single line per binding."
929 :type 'boolean)
913 930
914(defun apropos-print (do-keys spacing &optional text nosubst) 931(defun apropos-print (do-keys spacing &optional text nosubst)
915 "Output result of apropos searching into buffer `*Apropos*'. 932 "Output result of apropos searching into buffer `*Apropos*'.
@@ -971,51 +988,52 @@ If non-nil TEXT is a string that will be printed as a heading."
971 (cadr apropos-item)) 988 (cadr apropos-item))
972 (insert " (" (number-to-string (cadr apropos-item)) ") ")) 989 (insert " (" (number-to-string (cadr apropos-item)) ") "))
973 ;; Calculate key-bindings if we want them. 990 ;; Calculate key-bindings if we want them.
974 (and do-keys 991 (unless apropos-compact-layout
975 (commandp symbol) 992 (and do-keys
976 (not (eq symbol 'self-insert-command)) 993 (commandp symbol)
977 (indent-to 30 1) 994 (not (eq symbol 'self-insert-command))
978 (if (let ((keys 995 (indent-to 30 1)
979 (with-current-buffer old-buffer 996 (if (let ((keys
980 (where-is-internal symbol))) 997 (with-current-buffer old-buffer
981 filtered) 998 (where-is-internal symbol)))
982 ;; Copy over the list of key sequences, 999 filtered)
983 ;; omitting any that contain a buffer or a frame. 1000 ;; Copy over the list of key sequences,
984 ;; FIXME: Why omit keys that contain buffers and 1001 ;; omitting any that contain a buffer or a frame.
985 ;; frames? This looks like a bad workaround rather 1002 ;; FIXME: Why omit keys that contain buffers and
986 ;; than a proper fix. Does anybod know what problem 1003 ;; frames? This looks like a bad workaround rather
987 ;; this is trying to address? --Stef 1004 ;; than a proper fix. Does anybod know what problem
988 (dolist (key keys) 1005 ;; this is trying to address? --Stef
989 (let ((i 0) 1006 (dolist (key keys)
990 loser) 1007 (let ((i 0)
991 (while (< i (length key)) 1008 loser)
992 (if (or (framep (aref key i)) 1009 (while (< i (length key))
993 (bufferp (aref key i))) 1010 (if (or (framep (aref key i))
994 (setq loser t)) 1011 (bufferp (aref key i)))
995 (setq i (1+ i))) 1012 (setq loser t))
996 (or loser 1013 (setq i (1+ i)))
997 (push key filtered)))) 1014 (or loser
998 (setq item filtered)) 1015 (push key filtered))))
999 ;; Convert the remaining keys to a string and insert. 1016 (setq item filtered))
1000 (insert 1017 ;; Convert the remaining keys to a string and insert.
1001 (mapconcat 1018 (insert
1002 (lambda (key) 1019 (mapconcat
1003 (setq key (condition-case () 1020 (lambda (key)
1004 (key-description key) 1021 (setq key (condition-case ()
1005 (error))) 1022 (key-description key)
1006 (if apropos-keybinding-face 1023 (error)))
1007 (put-text-property 0 (length key) 1024 (if apropos-keybinding-face
1008 'face apropos-keybinding-face 1025 (put-text-property 0 (length key)
1009 key)) 1026 'face apropos-keybinding-face
1010 key) 1027 key))
1011 item ", ")) 1028 key)
1012 (insert "M-x ... RET") 1029 item ", "))
1013 (when apropos-keybinding-face 1030 (insert "M-x ... RET")
1014 (put-text-property (- (point) 11) (- (point) 8) 1031 (when apropos-keybinding-face
1015 'face apropos-keybinding-face) 1032 (put-text-property (- (point) 11) (- (point) 8)
1016 (put-text-property (- (point) 3) (point) 1033 'face apropos-keybinding-face)
1017 'face apropos-keybinding-face)))) 1034 (put-text-property (- (point) 3) (point)
1018 (terpri) 1035 'face apropos-keybinding-face))))
1036 (terpri))
1019 (apropos-print-doc 2 1037 (apropos-print-doc 2
1020 (if (commandp symbol) 1038 (if (commandp symbol)
1021 'apropos-command 1039 'apropos-command
@@ -1028,6 +1046,8 @@ If non-nil TEXT is a string that will be printed as a heading."
1028 (apropos-print-doc 6 'apropos-face t) 1046 (apropos-print-doc 6 'apropos-face t)
1029 (apropos-print-doc 5 'apropos-widget t) 1047 (apropos-print-doc 5 'apropos-widget t)
1030 (apropos-print-doc 4 'apropos-plist nil)) 1048 (apropos-print-doc 4 'apropos-plist nil))
1049 (set (make-local-variable 'truncate-partial-width-windows) t)
1050 (set (make-local-variable 'truncate-lines) t)
1031 (setq buffer-read-only t)))) 1051 (setq buffer-read-only t))))
1032 (prog1 apropos-accumulator 1052 (prog1 apropos-accumulator
1033 (setq apropos-accumulator ()))) ; permit gc 1053 (setq apropos-accumulator ()))) ; permit gc
@@ -1045,19 +1065,25 @@ If non-nil TEXT is a string that will be printed as a heading."
1045 1065
1046(defun apropos-print-doc (i type do-keys) 1066(defun apropos-print-doc (i type do-keys)
1047 (when (stringp (setq i (nth i apropos-item))) 1067 (when (stringp (setq i (nth i apropos-item)))
1048 (insert " ") 1068 (if apropos-compact-layout
1049 (insert-text-button (button-type-get type 'apropos-label) 1069 (insert (propertize "\t" 'display '(space :align-to 32)) " ")
1050 'type type 1070 (insert " "))
1051 ;; Can't use the default button face, since 1071 ;; If the query is only for a single type, there's
1052 ;; user may have changed the variable! 1072 ;; no point writing it over and over again.
1053 ;; Just say `no' to variables containing faces! 1073 (when apropos-multi-type
1054 'face apropos-label-face 1074 (insert-text-button
1055 'apropos-symbol (car apropos-item)) 1075 (if apropos-compact-layout
1056 (insert ": ") 1076 (button-type-get type 'apropos-label)
1057 (insert (if do-keys (substitute-command-keys i) i)) 1077 (format "<%s>" (button-type-get type 'apropos-short-label)))
1078 'type type
1079 ;; Can't use the default button face, since user may have changed the
1080 ;; variable! Just say `no' to variables containing faces!
1081 'face apropos-label-face
1082 'apropos-symbol (car apropos-item))
1083 (insert (if apropos-compact-layout " " ": ")))
1084 (insert (if do-keys (substitute-command-keys i) i))
1058 (or (bolp) (terpri)))) 1085 (or (bolp) (terpri))))
1059 1086
1060
1061(defun apropos-follow () 1087(defun apropos-follow ()
1062 "Invokes any button at point, otherwise invokes the nearest label button." 1088 "Invokes any button at point, otherwise invokes the nearest label button."
1063 (interactive) 1089 (interactive)