428
+ − 1 ;;; help.el --- help commands for XEmacs.
+ − 2
+ − 3 ;; Copyright (C) 1985, 1986, 1992-4, 1997 Free Software Foundation, Inc.
2537
+ − 4 ;; Copyright (C) 2001, 2002, 2003 Ben Wing.
428
+ − 5
+ − 6 ;; Maintainer: FSF
+ − 7 ;; Keywords: help, internal, dumped
+ − 8
+ − 9 ;; This file is part of XEmacs.
+ − 10
+ − 11 ;; XEmacs is free software; you can redistribute it and/or modify it
+ − 12 ;; under the terms of the GNU General Public License as published by
+ − 13 ;; the Free Software Foundation; either version 2, or (at your option)
+ − 14 ;; any later version.
+ − 15
+ − 16 ;; XEmacs is distributed in the hope that it will be useful, but
+ − 17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
+ − 18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ − 19 ;; General Public License for more details.
+ − 20
+ − 21 ;; You should have received a copy of the GNU General Public License
+ − 22 ;; along with XEmacs; see the file COPYING. If not, write to the
+ − 23 ;; Free Software Foundation, 59 Temple Place - Suite 330,
+ − 24 ;; Boston, MA 02111-1307, USA.
+ − 25
+ − 26 ;;; Synched up with: FSF 19.30.
+ − 27
+ − 28 ;;; Commentary:
+ − 29
+ − 30 ;; This file is dumped with XEmacs.
+ − 31
+ − 32 ;; This code implements XEmacs's on-line help system, the one invoked by
+ − 33 ;;`M-x help-for-help'.
+ − 34
+ − 35 ;; 06/11/1997 -- Converted to use char-after instead of broken
+ − 36 ;; following-char. -slb
+ − 37
+ − 38 ;;; Code:
+ − 39
+ − 40 ;; Get the macro make-help-screen when this is compiled,
+ − 41 ;; or run interpreted, but not when the compiled code is loaded.
+ − 42 (eval-when-compile (require 'help-macro))
+ − 43
+ − 44 (defgroup help nil
+ − 45 "Support for on-line help systems."
+ − 46 :group 'emacs)
+ − 47
+ − 48 (defgroup help-appearance nil
+ − 49 "Appearance of help buffers."
+ − 50 :group 'help)
+ − 51
+ − 52 (defvar help-map (let ((map (make-sparse-keymap)))
+ − 53 (set-keymap-name map 'help-map)
+ − 54 (set-keymap-prompt
444
+ − 55 map (gettext "(Type ? for further options)"))
428
+ − 56 map)
+ − 57 "Keymap for characters following the Help key.")
+ − 58
+ − 59 ;; global-map definitions moved to keydefs.el
+ − 60 (fset 'help-command help-map)
+ − 61
+ − 62 (define-key help-map (vector help-char) 'help-for-help)
+ − 63 (define-key help-map "?" 'help-for-help)
+ − 64 (define-key help-map 'help 'help-for-help)
+ − 65 (define-key help-map '(f1) 'help-for-help)
+ − 66
+ − 67 (define-key help-map "a" 'hyper-apropos) ; 'command-apropos in FSFmacs
502
+ − 68 (define-key help-map "A" 'command-hyper-apropos)
+ − 69 ;; #### should be hyper-apropos-documentation, once that's written.
+ − 70 (define-key help-map "\C-a" 'apropos-documentation)
428
+ − 71
+ − 72 (define-key help-map "b" 'describe-bindings)
+ − 73 (define-key help-map "B" 'describe-beta)
+ − 74
502
+ − 75 (define-key help-map "c" 'describe-key-briefly)
428
+ − 76 (define-key help-map "C" 'customize)
502
+ − 77 ;; FSFmacs has Info-goto-emacs-command-node on C-f, no binding
+ − 78 ;; for Info-elisp-ref
+ − 79 (define-key help-map "\C-c" 'Info-goto-emacs-command-node)
428
+ − 80
+ − 81 (define-key help-map "d" 'describe-function)
502
+ − 82 (define-key help-map "\C-d" 'describe-distribution)
+ − 83
+ − 84 (define-key help-map "e" (if (fboundp 'view-last-error) 'view-last-error
+ − 85 'describe-last-error))
+ − 86
428
+ − 87 (define-key help-map "f" 'describe-function)
502
+ − 88 ;; #### not a good interface. no way to specify that C-h is preferred
+ − 89 ;; as a prefix and not BS. should instead be specified as part of
+ − 90 ;; `define-key'.
+ − 91 ;; (put 'describe-function 'preferred-key-sequence "\C-hf")
428
+ − 92 (define-key help-map "F" 'xemacs-local-faq)
502
+ − 93 (define-key help-map "\C-f" 'Info-elisp-ref)
428
+ − 94
+ − 95 (define-key help-map "i" 'info)
502
+ − 96 (define-key help-map "I" 'Info-search-index-in-xemacs-and-lispref)
+ − 97 (define-key help-map "\C-i" 'Info-query)
+ − 98
+ − 99 (define-key help-map "k" 'describe-key)
+ − 100 (define-key help-map "\C-k" 'Info-goto-emacs-key-command-node)
428
+ − 101
+ − 102 (define-key help-map "l" 'view-lossage)
502
+ − 103 (define-key help-map "\C-l" 'describe-copying) ; on \C-c in FSFmacs
428
+ − 104
+ − 105 (define-key help-map "m" 'describe-mode)
+ − 106
502
+ − 107 (define-key help-map "n" 'view-emacs-news)
428
+ − 108 (define-key help-map "\C-n" 'view-emacs-news)
+ − 109
+ − 110 (define-key help-map "p" 'finder-by-keyword)
502
+ − 111 (define-key help-map "\C-p" 'describe-pointer)
3074
+ − 112 (define-key help-map "P" 'view-xemacs-problems)
502
+ − 113
+ − 114 (define-key help-map "q" 'help-quit)
428
+ − 115
+ − 116 ;; Do this right with an autoload cookie in finder.el.
+ − 117 ;;(autoload 'finder-by-keyword "finder"
+ − 118 ;; "Find packages matching a given keyword." t)
+ − 119
+ − 120 (define-key help-map "s" 'describe-syntax)
502
+ − 121 (define-key help-map "S" 'view-sample-init-el)
428
+ − 122
+ − 123 (define-key help-map "t" 'help-with-tutorial)
+ − 124
+ − 125 (define-key help-map "v" 'describe-variable)
+ − 126
502
+ − 127 (define-key help-map "w" 'where-is)
+ − 128 (define-key help-map "\C-w" 'describe-no-warranty)
428
+ − 129
502
+ − 130 ;; #### It would be nice if the code below to add hyperlinks was
+ − 131 ;; generalized. We would probably need a "hyperlink mode" from which
+ − 132 ;; help-mode is derived. This means we probably need multiple
+ − 133 ;; inheritance of modes! Thankfully this is not hard to implement; we
+ − 134 ;; already have the ability for a keymap to have multiple parents.
+ − 135 ;; However, we'd have to define any multiply-inherited-from modes using
+ − 136 ;; a standard `define-mode' construction instead of manually doing it,
+ − 137 ;; because we don't want each guy calling `kill-all-local-variables' and
+ − 138 ;; messing up the previous one.
428
+ − 139
+ − 140 (define-derived-mode help-mode view-major-mode "Help"
+ − 141 "Major mode for viewing help text.
+ − 142 Entry to this mode runs the normal hook `help-mode-hook'.
+ − 143 Commands:
+ − 144 \\{help-mode-map}"
+ − 145 )
+ − 146
+ − 147 (define-key help-mode-map "q" 'help-mode-quit)
+ − 148 (define-key help-mode-map "Q" 'help-mode-bury)
+ − 149 (define-key help-mode-map "f" 'find-function-at-point)
+ − 150 (define-key help-mode-map "d" 'describe-function-at-point)
+ − 151 (define-key help-mode-map "v" 'describe-variable-at-point)
+ − 152 (define-key help-mode-map "i" 'Info-elisp-ref)
+ − 153 (define-key help-mode-map "c" 'customize-variable)
+ − 154 (define-key help-mode-map [tab] 'help-next-symbol)
+ − 155 (define-key help-mode-map [(shift tab)] 'help-prev-symbol)
+ − 156 (define-key help-mode-map "n" 'help-next-section)
+ − 157 (define-key help-mode-map "p" 'help-prev-section)
+ − 158
1123
+ − 159 (define-derived-mode temp-buffer-mode view-major-mode "Temp"
+ − 160 "Major mode for viewing temporary buffers.
+ − 161 Exit using \\<temp-buffer-mode-map>\\[help-mode-quit].
+ − 162
+ − 163 Entry to this mode runs the normal hook `temp-buffer-mode-hook'.
+ − 164 Commands:
+ − 165 \\{temp-buffer-mode-map}"
+ − 166 )
+ − 167
+ − 168 (define-key temp-buffer-mode-map "q" 'help-mode-quit)
+ − 169 (define-key temp-buffer-mode-map "Q" 'help-mode-bury)
+ − 170
428
+ − 171 (defun describe-function-at-point ()
+ − 172 "Describe directly the function at point in the other window."
+ − 173 (interactive)
+ − 174 (let ((symb (function-at-point)))
+ − 175 (when symb
+ − 176 (describe-function symb))))
+ − 177
+ − 178 (defun describe-variable-at-point ()
+ − 179 "Describe directly the variable at point in the other window."
+ − 180 (interactive)
+ − 181 (let ((symb (variable-at-point)))
+ − 182 (when symb
+ − 183 (describe-variable symb))))
+ − 184
+ − 185 (defun help-next-symbol ()
+ − 186 "Move point to the next quoted symbol."
+ − 187 (interactive)
+ − 188 (search-forward "`" nil t))
+ − 189
+ − 190 (defun help-prev-symbol ()
+ − 191 "Move point to the previous quoted symbol."
+ − 192 (interactive)
+ − 193 (search-backward "'" nil t))
+ − 194
+ − 195 (defun help-next-section ()
+ − 196 "Move point to the next quoted symbol."
+ − 197 (interactive)
+ − 198 (search-forward-regexp "^\\w+:" nil t))
+ − 199
+ − 200 (defun help-prev-section ()
+ − 201 "Move point to the previous quoted symbol."
+ − 202 (interactive)
+ − 203 (search-backward-regexp "^\\w+:" nil t))
+ − 204
+ − 205 (defun help-mode-bury ()
+ − 206 "Bury the help buffer, possibly restoring the previous window configuration."
+ − 207 (interactive)
+ − 208 (help-mode-quit t))
+ − 209
+ − 210 (defun help-mode-quit (&optional bury)
+ − 211 "Exit from help mode, possibly restoring the previous window configuration.
+ − 212 If the optional argument BURY is non-nil, the help buffer is buried,
+ − 213 otherwise it is killed."
+ − 214 (interactive)
+ − 215 (let ((buf (current-buffer)))
442
+ − 216 (cond (help-window-config
+ − 217 (set-window-configuration help-window-config))
428
+ − 218 ((not (one-window-p))
+ − 219 (delete-window)))
+ − 220 (if bury
+ − 221 (bury-buffer buf)
+ − 222 (kill-buffer buf))))
+ − 223
+ − 224 (defun help-quit ()
+ − 225 (interactive)
+ − 226 nil)
+ − 227
771
+ − 228 (define-obsolete-function-alias 'deprecated-help-command 'help-for-help)
428
+ − 229
+ − 230 ;;(define-key global-map 'backspace 'deprecated-help-command)
+ − 231
771
+ − 232 (defconst tutorial-supported-languages
+ − 233 '(
+ − 234 ("Croatian" hr iso-8859-2)
+ − 235 ("Czech" cs iso-8859-2)
+ − 236 ("Dutch" nl iso-8859-1)
+ − 237 ("English" nil raw-text)
+ − 238 ("French" fr iso-8859-1)
+ − 239 ("German" de iso-8859-1)
+ − 240 ("Norwegian" no iso-8859-1)
+ − 241 ("Polish" pl iso-8859-2)
+ − 242 ("Romanian" ro iso-8859-2)
+ − 243 ("Slovak" sk iso-8859-2)
+ − 244 ("Slovenian" sl iso-8859-2)
+ − 245 ("Spanish" es iso-8859-1)
+ − 246 ("Swedish" se iso-8859-1)
+ − 247 )
+ − 248 "Alist of supported languages in TUTORIAL files.
+ − 249 Add languages here, as more are translated.")
+ − 250
+ − 251 ;; TUTORIAL arg is XEmacs addition
+ − 252 (defun help-with-tutorial (&optional tutorial language)
+ − 253 "Select the XEmacs learn-by-doing tutorial.
+ − 254 Optional arg TUTORIAL specifies the tutorial file; if not specified or
+ − 255 if this command is invoked interactively, the tutorial appropriate to
+ − 256 the current language environment is used. If there is no tutorial
+ − 257 written in that language, or if this version of XEmacs has no
+ − 258 international (Mule) support, the English-language tutorial is used.
+ − 259 With a prefix argument, you are asked to select which language."
+ − 260 (interactive "i\nP")
+ − 261 (when (and language (consp language))
+ − 262 (setq language
+ − 263 (if (featurep 'mule)
+ − 264 (or (declare-fboundp (read-language-name 'tutorial "Language: "))
+ − 265 (error "No tutorial file of the specified language"))
+ − 266 (let ((completion-ignore-case t))
+ − 267 (completing-read "Language: "
+ − 268 tutorial-supported-languages nil t)))))
+ − 269 (or language
+ − 270 (setq language
+ − 271 (if (featurep 'mule) (declare-boundp current-language-environment)
+ − 272 "English")))
+ − 273 (or tutorial
+ − 274 (setq tutorial
+ − 275 (cond ((featurep 'mule)
+ − 276 (or (declare-fboundp (get-language-info language 'tutorial))
+ − 277 "TUTORIAL"))
+ − 278 ((equal language "English") "TUTORIAL")
+ − 279 (t (format "TUTORIAL.%s"
+ − 280 (cadr (assoc language
+ − 281 tutorial-supported-languages)))))))
+ − 282 (let ((file (expand-file-name tutorial "~")))
+ − 283 (delete-other-windows)
+ − 284 (let ((buffer (or (get-file-buffer file)
+ − 285 (create-file-buffer file)))
+ − 286 (window-configuration (current-window-configuration)))
+ − 287 (condition-case error-data
+ − 288 (progn
+ − 289 (switch-to-buffer buffer)
+ − 290 (setq buffer-file-name file)
+ − 291 (setq default-directory (expand-file-name "~/"))
+ − 292 (setq buffer-auto-save-file-name nil)
+ − 293 ;; Because of non-Mule users, TUTORIALs are not coded
+ − 294 ;; independently, so we must guess the coding according to
+ − 295 ;; the language.
+ − 296 (let ((coding-system-for-read
+ − 297 (if (featurep 'mule)
+ − 298 (with-fboundp 'get-language-info
+ − 299 (or (get-language-info language
+ − 300 'tutorial-coding-system)
+ − 301 (car (get-language-info language
+ − 302 'coding-system))))
+ − 303 (nth 2 (assoc language tutorial-supported-languages)))))
+ − 304 (insert-file-contents (locate-data-file tutorial)))
+ − 305 (goto-char (point-min))
+ − 306 ;; [The 'didactic' blank lines: possibly insert blank lines
+ − 307 ;; around <<nya nya nya>> and replace << >> with [ ].] No more
+ − 308 ;; didactic blank lines. It was just a bad idea, anyway. I
+ − 309 ;; rewrote the TUTORIAL so it doesn't need them. However, some
+ − 310 ;; tutorials in other languages haven't yet been updated. ####
+ − 311 ;; Delete this code when they're all updated.
+ − 312 (if (re-search-forward "^<<.+>>" nil t)
+ − 313 (let ((n (- (window-height (selected-window))
+ − 314 (count-lines (point-min) (point-at-bol))
+ − 315 6)))
+ − 316 (if (< n 12)
+ − 317 (progn (beginning-of-line) (kill-line))
+ − 318 ;; Some people get confused by the large gap
+ − 319 (delete-backward-char 2)
+ − 320 (insert "]")
+ − 321 (beginning-of-line)
+ − 322 (save-excursion
+ − 323 (delete-char 2)
+ − 324 (insert "["))
+ − 325 (newline (/ n 2))
+ − 326 (next-line 1)
+ − 327 (newline (- n (/ n 2))))))
+ − 328 (goto-char (point-min))
+ − 329 (set-buffer-modified-p nil))
+ − 330 ;; TUTORIAL was not found: kill the buffer and restore the
+ − 331 ;; window configuration.
+ − 332 (file-error (kill-buffer buffer)
+ − 333 (set-window-configuration window-configuration)
+ − 334 ;; Now, signal the error
+ − 335 (signal (car error-data) (cdr error-data)))))))
428
+ − 336
+ − 337 ;; used by describe-key, describe-key-briefly, insert-key-binding, etc.
+ − 338 (defun key-or-menu-binding (key &optional menu-flag)
+ − 339 "Return the command invoked by KEY.
+ − 340 Like `key-binding', but handles menu events and toolbar presses correctly.
+ − 341 KEY is any value returned by `next-command-event'.
+ − 342 MENU-FLAG is a symbol that should be set to t if KEY is a menu event,
444
+ − 343 or nil otherwise."
428
+ − 344 (let (defn)
+ − 345 (and menu-flag (set menu-flag nil))
+ − 346 ;; If the key typed was really a menu selection, grab the form out
+ − 347 ;; of the event object and intuit the function that would be called,
+ − 348 ;; and describe that instead.
+ − 349 (if (and (vectorp key) (= 1 (length key))
+ − 350 (or (misc-user-event-p (aref key 0))
+ − 351 (eq (car-safe (aref key 0)) 'menu-selection)))
+ − 352 (let ((event (aref key 0)))
+ − 353 (setq defn (if (eventp event)
+ − 354 (list (event-function event) (event-object event))
+ − 355 (cdr event)))
+ − 356 (and menu-flag (set menu-flag t))
+ − 357 (when (eq (car defn) 'eval)
+ − 358 (setq defn (car (cdr defn))))
+ − 359 (when (eq (car-safe defn) 'call-interactively)
+ − 360 (setq defn (car (cdr defn))))
+ − 361 (when (and (consp defn) (null (cdr defn)))
+ − 362 (setq defn (car defn))))
+ − 363 ;; else
+ − 364 (setq defn (key-binding key)))
+ − 365 ;; kludge: if a toolbar button was pressed on, try to find the
+ − 366 ;; binding of the toolbar button.
+ − 367 (if (and (eq defn 'press-toolbar-button)
+ − 368 (vectorp key)
+ − 369 (button-press-event-p (aref key (1- (length key)))))
+ − 370 ;; wait for the button release. We're on shaky ground here ...
+ − 371 (let ((event (next-command-event))
+ − 372 button)
+ − 373 (if (and (button-release-event-p event)
+ − 374 (event-over-toolbar-p event)
+ − 375 (eq 'release-and-activate-toolbar-button
+ − 376 (key-binding (vector event)))
+ − 377 (setq button (event-toolbar-button event)))
+ − 378 (toolbar-button-callback button)
+ − 379 ;; if anything went wrong, try returning the binding of
+ − 380 ;; the button-up event, of the original binding
+ − 381 (or (key-or-menu-binding (vector event))
+ − 382 defn)))
+ − 383 ;; no toolbar kludge
+ − 384 defn)
+ − 385 ))
+ − 386
+ − 387 (defun describe-key-briefly (key &optional insert)
+ − 388 "Print the name of the function KEY invokes. KEY is a string.
+ − 389 If INSERT (the prefix arg) is non-nil, insert the message in the buffer."
+ − 390 (interactive "kDescribe key briefly: \nP")
+ − 391 (let ((standard-output (if insert (current-buffer) t))
+ − 392 defn menup)
+ − 393 (setq defn (key-or-menu-binding key 'menup))
+ − 394 (if (or (null defn) (integerp defn))
+ − 395 (princ (format "%s is undefined" (key-description key)))
+ − 396 ;; If it's a keyboard macro which trivially invokes another command,
+ − 397 ;; document that instead.
+ − 398 (if (or (stringp defn) (vectorp defn))
+ − 399 (setq defn (or (key-binding defn)
+ − 400 defn)))
+ − 401 (let ((last-event (and (vectorp key)
+ − 402 (aref key (1- (length key))))))
+ − 403 (princ (format (cond (insert
+ − 404 "%s (%s)")
+ − 405 ((or (button-press-event-p last-event)
+ − 406 (button-release-event-p last-event))
+ − 407 (gettext "%s at that spot runs the command %s"))
+ − 408 (t
+ − 409 (gettext "%s runs the command %s")))
+ − 410 ;; This used to say 'This menu item' but it
+ − 411 ;; could also be a scrollbar event. We can't
+ − 412 ;; distinguish at the moment.
+ − 413 (if menup
+ − 414 (if insert "item" "This item")
+ − 415 (key-description key))
+ − 416 (if (symbolp defn) defn (prin1-to-string defn))))))))
+ − 417
+ − 418 ;; #### this is a horrible piece of shit function that should
+ − 419 ;; not exist. In FSF 19.30 this function has gotten three times
+ − 420 ;; as long and has tons and tons of dumb shit checking
+ − 421 ;; special-display-buffer-names and such crap. I absolutely
+ − 422 ;; refuse to insert that Ebolification here. I wanted to delete
+ − 423 ;; this function entirely but Mly bitched.
+ − 424 ;;
+ − 425 ;; If your user-land code calls this function, rewrite it to
+ − 426 ;; call with-displaying-help-buffer.
+ − 427
+ − 428 (defun print-help-return-message (&optional function)
+ − 429 "Display or return message saying how to restore windows after help command.
+ − 430 Computes a message and applies the optional argument FUNCTION to it.
+ − 431 If FUNCTION is nil, applies `message' to it, thus printing it."
+ − 432 (and (not (get-buffer-window standard-output))
+ − 433 (funcall
+ − 434 (or function 'message)
+ − 435 (concat
+ − 436 (substitute-command-keys
+ − 437 (if (one-window-p t)
+ − 438 (if pop-up-windows
+ − 439 (gettext "Type \\[delete-other-windows] to remove help window.")
+ − 440 (gettext "Type \\[switch-to-buffer] RET to remove help window."))
+ − 441 (gettext "Type \\[switch-to-buffer-other-window] RET to restore the other window.")))
+ − 442 (substitute-command-keys
+ − 443 (gettext " \\[scroll-other-window] to scroll the help."))))))
+ − 444
+ − 445 (defcustom help-selects-help-window t
+ − 446 "*If nil, use the \"old Emacs\" behavior for Help buffers.
+ − 447 This just displays the buffer in another window, rather than selecting
+ − 448 the window."
+ − 449 :type 'boolean
+ − 450 :group 'help-appearance)
+ − 451
+ − 452 (defcustom help-max-help-buffers 10
+ − 453 "*Maximum help buffers to allow before they start getting killed.
+ − 454 If this is a positive integer, before a help buffer is displayed
+ − 455 by `with-displaying-help-buffer', any excess help buffers which
+ − 456 are not being displayed are first killed. Otherwise, if it is
+ − 457 zero or nil, only one help buffer, \"*Help*\" is ever used."
+ − 458 :type '(choice integer (const :tag "None" nil))
+ − 459 :group 'help-appearance)
+ − 460
+ − 461 (defvar help-buffer-list nil
+ − 462 "List of help buffers used by `help-register-and-maybe-prune-excess'")
+ − 463
+ − 464 (defun help-register-and-maybe-prune-excess (newbuf)
2030
+ − 465 "Register help buffer named NEWBUF and possibly kill excess ones."
+ − 466 ;; don't let client code pass us bogus NEWBUF---if it gets in the list,
+ − 467 ;; help can become unusable
+ − 468 (unless (stringp newbuf)
+ − 469 (error 'wrong-type-argument "help buffer name must be string" newbuf))
428
+ − 470 ;; remove new buffer from list
+ − 471 (setq help-buffer-list (remove newbuf help-buffer-list))
+ − 472 ;; maybe kill excess help buffers
+ − 473 (if (and (integerp help-max-help-buffers)
+ − 474 (> (length help-buffer-list) help-max-help-buffers))
+ − 475 (let ((keep-list nil)
+ − 476 (num-kill (- (length help-buffer-list)
+ − 477 help-max-help-buffers)))
+ − 478 (while help-buffer-list
+ − 479 (let ((buf (car help-buffer-list)))
+ − 480 (if (and (or (equal buf newbuf) (get-buffer buf))
+ − 481 (string-match "^*Help" buf)
+ − 482 (save-excursion (set-buffer buf)
+ − 483 (eq major-mode 'help-mode)))
+ − 484 (if (and (>= num-kill (length help-buffer-list))
+ − 485 (not (get-buffer-window buf t t)))
+ − 486 (kill-buffer buf)
+ − 487 (setq keep-list (cons buf keep-list)))))
+ − 488 (setq help-buffer-list (cdr help-buffer-list)))
+ − 489 (setq help-buffer-list (nreverse keep-list))))
+ − 490 ;; push new buffer
+ − 491 (setq help-buffer-list (cons newbuf help-buffer-list)))
+ − 492
+ − 493 (defvar help-buffer-prefix-string "Help"
+ − 494 "Initial string to use in constructing help buffer names.
2030
+ − 495 You should never set this directly, only let-bind it.")
428
+ − 496
+ − 497 (defun help-buffer-name (name)
+ − 498 "Return a name for a Help buffer using string NAME for context."
+ − 499 (if (and (integerp help-max-help-buffers)
+ − 500 (> help-max-help-buffers 0)
+ − 501 (stringp name))
+ − 502 (if help-buffer-prefix-string
+ − 503 (format "*%s: %s*" help-buffer-prefix-string name)
+ − 504 (format "*%s*" name))
+ − 505 (format "*%s*" help-buffer-prefix-string)))
+ − 506
863
+ − 507 ;; with-displaying-help-buffer
428
+ − 508
+ − 509 ;; #### Should really be a macro to eliminate the requirement of
+ − 510 ;; caller to code a lambda form in THUNK -- mrb
+ − 511
+ − 512 ;; #### BEFORE you rush to make this a macro, think about backward
+ − 513 ;; compatibility. The right way would be to create a macro with
+ − 514 ;; another name (which is a shame, because w-d-h-b is a perfect name
+ − 515 ;; for a macro) that uses with-displaying-help-buffer internally.
+ − 516
442
+ − 517 (defcustom mode-for-help 'help-mode
+ − 518 "*Mode that help buffers are put into.")
+ − 519
1123
+ − 520 (defcustom mode-for-temp-buffer 'temp-buffer-mode
+ − 521 "*Mode that help buffers are put into.")
+ − 522
442
+ − 523 (defvar help-sticky-window nil
+ − 524 ;; Window into which help buffers will be displayed, rather than
+ − 525 ;; always searching for a new one. This is INTERNAL and liable to
+ − 526 ;; change its interface and/or name at any moment. It should be
+ − 527 ;; bound, not set.
+ − 528 )
+ − 529
+ − 530 (defvar help-window-config nil)
+ − 531
+ − 532 (make-variable-buffer-local 'help-window-config)
+ − 533 (put 'help-window-config 'permanent-local t)
+ − 534
1123
+ − 535 (defmacro with-displaying-temp-buffer (name &rest body)
2030
+ − 536 "Make a help buffer with given NAME and evaluate BODY, sending stdout there.
1123
+ − 537
+ − 538 Use this function for displaying information in temporary buffers, where the
+ − 539 user will typically view the information and then exit using
+ − 540 \\<temp-buffer-mode-map>\\[help-mode-quit].
863
+ − 541
2030
+ − 542 On exit from this form, the buffer is put into the mode specified in
+ − 543 `mode-for-temp-buffer' and displayed, typically in a popup window. Ie,
+ − 544 the buffer is a scratchpad which is displayed all at once in formatted
+ − 545 form.
+ − 546
+ − 547 N.B. Write to this buffer with functions like `princ', not `insert'."
1123
+ − 548 `(let* ((winconfig (current-window-configuration))
+ − 549 (was-one-window (one-window-p))
+ − 550 (buffer-name ,name)
+ − 551 (help-not-visible
+ − 552 (not (and (windows-of-buffer buffer-name) ;shortcut
+ − 553 (memq (selected-frame)
+ − 554 (mapcar 'window-frame
+ − 555 (windows-of-buffer buffer-name)))))))
428
+ − 556 (help-register-and-maybe-prune-excess buffer-name)
442
+ − 557 ;; if help-sticky-window is bogus or deleted, get rid of it.
+ − 558 (if (and help-sticky-window (or (not (windowp help-sticky-window))
+ − 559 (not (window-live-p help-sticky-window))))
+ − 560 (setq help-sticky-window nil))
+ − 561 (prog1
+ − 562 (let ((temp-buffer-show-function
+ − 563 (if help-sticky-window
+ − 564 #'(lambda (buffer)
+ − 565 (set-window-buffer help-sticky-window buffer))
+ − 566 temp-buffer-show-function)))
+ − 567 (with-output-to-temp-buffer buffer-name
1123
+ − 568 (prog1 (progn ,@body)
442
+ − 569 (save-excursion
+ − 570 (set-buffer standard-output)
1123
+ − 571 (funcall mode-for-temp-buffer)))))
428
+ − 572 (let ((helpwin (get-buffer-window buffer-name)))
+ − 573 (when helpwin
1123
+ − 574 ;; If the temp buffer is already displayed on this
442
+ − 575 ;; frame, don't override the previous configuration
+ − 576 (when help-not-visible
+ − 577 (with-current-buffer (window-buffer helpwin)
+ − 578 (setq help-window-config winconfig)))
428
+ − 579 (when help-selects-help-window
+ − 580 (select-window helpwin))
+ − 581 (cond ((eq helpwin (selected-window))
+ − 582 (display-message 'command
1123
+ − 583 (substitute-command-keys "Type \\[help-mode-quit] to remove window, \\[scroll-up] to scroll the text.")))
428
+ − 584 (was-one-window
+ − 585 (display-message 'command
1123
+ − 586 (substitute-command-keys "Type \\[delete-other-windows] to remove window, \\[scroll-other-window] to scroll the text.")))
428
+ − 587 (t
+ − 588 (display-message 'command
1123
+ − 589 (substitute-command-keys "Type \\[switch-to-buffer-other-window] to restore the other window, \\[scroll-other-window] to scroll the text.")))))))))
+ − 590
+ − 591 (put 'with-displaying-temp-buffer 'lisp-indent-function 1)
+ − 592
+ − 593 (defun with-displaying-help-buffer (thunk &optional name)
+ − 594 "Form which makes a help buffer with given NAME and evaluates BODY there.
+ − 595 The actual name of the buffer is generated by the function `help-buffer-name'.
+ − 596
+ − 597 Use this function for displaying help when C-h something is pressed or
+ − 598 in similar situations. Do *not* use it when you are displaying a help
+ − 599 message and then prompting for input in the minibuffer -- this macro
+ − 600 usually selects the help buffer, which is not what you want in those
+ − 601 situations."
+ − 602 (let ((mode-for-temp-buffer mode-for-help))
+ − 603 (with-displaying-temp-buffer (help-buffer-name name)
+ − 604 (funcall thunk))))
428
+ − 605
+ − 606 (defun describe-key (key)
+ − 607 "Display documentation of the function invoked by KEY.
+ − 608 KEY is a string, or vector of events.
+ − 609 When called interactively, KEY may also be a menu selection."
+ − 610 (interactive "kDescribe key: ")
+ − 611 (let ((defn (key-or-menu-binding key))
+ − 612 (key-string (key-description key)))
+ − 613 (if (or (null defn) (integerp defn))
+ − 614 (message "%s is undefined" key-string)
+ − 615 (with-displaying-help-buffer
+ − 616 (lambda ()
+ − 617 (princ key-string)
+ − 618 (princ " runs ")
+ − 619 (if (symbolp defn)
+ − 620 (princ (format "`%s'" defn))
+ − 621 (princ defn))
+ − 622 (princ "\n\n")
+ − 623 (cond ((or (stringp defn) (vectorp defn))
+ − 624 (let ((cmd (key-binding defn)))
+ − 625 (if (not cmd)
+ − 626 (princ "a keyboard macro")
+ − 627 (progn
+ − 628 (princ "a keyboard macro which runs the command ")
+ − 629 (princ cmd)
+ − 630 (princ ":\n\n")
+ − 631 (if (documentation cmd) (princ (documentation cmd)))))))
+ − 632 ((and (consp defn) (not (eq 'lambda (car-safe defn))))
+ − 633 (let ((describe-function-show-arglist nil))
+ − 634 (describe-function-1 (car defn))))
+ − 635 ((symbolp defn)
+ − 636 (describe-function-1 defn))
+ − 637 ((documentation defn)
+ − 638 (princ (documentation defn)))
+ − 639 (t
+ − 640 (princ "not documented"))))
+ − 641 (format "key `%s'" key-string)))))
+ − 642
+ − 643 (defun describe-mode ()
+ − 644 "Display documentation of current major mode and minor modes.
+ − 645 For this to work correctly for a minor mode, the mode's indicator variable
+ − 646 \(listed in `minor-mode-alist') must also be a function whose documentation
+ − 647 describes the minor mode."
+ − 648 (interactive)
+ − 649 (with-displaying-help-buffer
+ − 650 (lambda ()
+ − 651 ;; XEmacs change: print the major-mode documentation before
+ − 652 ;; the minor modes.
+ − 653 (princ mode-name)
+ − 654 (princ " mode:\n")
+ − 655 (princ (documentation major-mode))
+ − 656 (princ "\n\n----\n\n")
+ − 657 (let ((minor-modes minor-mode-alist))
+ − 658 (while minor-modes
+ − 659 (let* ((minor-mode (car (car minor-modes)))
+ − 660 (indicator (car (cdr (car minor-modes)))))
+ − 661 ;; Document a minor mode if it is listed in minor-mode-alist,
+ − 662 ;; bound locally in this buffer, non-nil, and has a function
+ − 663 ;; definition.
+ − 664 (if (and (boundp minor-mode)
+ − 665 (symbol-value minor-mode)
+ − 666 (fboundp minor-mode))
+ − 667 (let ((pretty-minor-mode minor-mode))
+ − 668 (if (string-match "-mode\\'" (symbol-name minor-mode))
+ − 669 (setq pretty-minor-mode
+ − 670 (capitalize
+ − 671 (substring (symbol-name minor-mode)
+ − 672 0 (match-beginning 0)))))
+ − 673 (while (and (consp indicator) (extentp (car indicator)))
+ − 674 (setq indicator (cdr indicator)))
+ − 675 (while (and indicator (symbolp indicator))
+ − 676 (setq indicator (symbol-value indicator)))
732
+ − 677 (princ (format "%s minor mode (%s):\n"
+ − 678 pretty-minor-mode
+ − 679 (if indicator
+ − 680 (format "indicator%s" indicator)
+ − 681 "no indicator")))
428
+ − 682 (princ (documentation minor-mode))
+ − 683 (princ "\n\n----\n\n"))))
+ − 684 (setq minor-modes (cdr minor-modes)))))
+ − 685 (format "%s mode" mode-name)))
+ − 686
+ − 687 ;; So keyboard macro definitions are documented correctly
+ − 688 (fset 'defining-kbd-macro (symbol-function 'start-kbd-macro))
+ − 689
462
+ − 690 ;; view a read-only file intelligently
+ − 691 (defun Help-find-file (file)
+ − 692 (if (fboundp 'view-file)
+ − 693 (view-file file)
+ − 694 (find-file-read-only file)
+ − 695 (goto-char (point-min))))
+ − 696
428
+ − 697 (defun describe-distribution ()
+ − 698 "Display info on how to obtain the latest version of XEmacs."
+ − 699 (interactive)
2537
+ − 700 (save-window-excursion
+ − 701 (info)
+ − 702 (Info-find-node "xemacs-faq" "Q1.1.1"))
+ − 703 (switch-to-buffer "*info*"))
428
+ − 704
+ − 705 (defun describe-beta ()
+ − 706 "Display info on how to deal with Beta versions of XEmacs."
+ − 707 (interactive)
2537
+ − 708 (save-window-excursion
+ − 709 (info "(beta)Top"))
+ − 710 (switch-to-buffer "*info*"))
428
+ − 711
+ − 712 (defun describe-copying ()
+ − 713 "Display info on how you may redistribute copies of XEmacs."
+ − 714 (interactive)
462
+ − 715 (Help-find-file (locate-data-file "COPYING")))
428
+ − 716
+ − 717 (defun describe-pointer ()
+ − 718 "Show a list of all defined mouse buttons, and their definitions."
+ − 719 (interactive)
+ − 720 (describe-bindings nil t))
+ − 721
+ − 722 (defun describe-no-warranty ()
+ − 723 "Display info on all the kinds of warranty XEmacs does NOT have."
+ − 724 (interactive)
+ − 725 (describe-copying)
+ − 726 (let (case-fold-search)
+ − 727 (search-forward "NO WARRANTY")
+ − 728 (recenter 0)))
+ − 729
+ − 730 (defun describe-bindings (&optional prefix mouse-only-p)
+ − 731 "Show a list of all defined keys, and their definitions.
+ − 732 The list is put in a buffer, which is displayed.
444
+ − 733 If optional first argument PREFIX is supplied, only commands
+ − 734 which start with that sequence of keys are described.
+ − 735 If optional second argument MOUSE-ONLY-P (prefix arg, interactively)
+ − 736 is non-nil then only the mouse bindings are displayed."
428
+ − 737 (interactive (list nil current-prefix-arg))
+ − 738 (with-displaying-help-buffer
+ − 739 (lambda ()
+ − 740 (describe-bindings-1 prefix mouse-only-p))
+ − 741 (format "bindings for %s" major-mode)))
+ − 742
+ − 743 (defun describe-bindings-1 (&optional prefix mouse-only-p)
+ − 744 (let ((heading (if mouse-only-p
+ − 745 (gettext "button binding\n------ -------\n")
+ − 746 (gettext "key binding\n--- -------\n")))
+ − 747 (buffer (current-buffer))
+ − 748 (minor minor-mode-map-alist)
430
+ − 749 (extent-maps (mapcar-extents
+ − 750 'extent-keymap
+ − 751 nil (current-buffer) (point) (point) nil 'keymap))
428
+ − 752 (local (current-local-map))
+ − 753 (shadow '()))
+ − 754 (set-buffer standard-output)
430
+ − 755 (while extent-maps
+ − 756 (insert "Bindings for Text Region:\n"
+ − 757 heading)
+ − 758 (describe-bindings-internal
+ − 759 (car extent-maps) nil shadow prefix mouse-only-p)
+ − 760 (insert "\n")
+ − 761 (setq shadow (cons (car extent-maps) shadow)
+ − 762 extent-maps (cdr extent-maps)))
428
+ − 763 (while minor
+ − 764 (let ((sym (car (car minor)))
+ − 765 (map (cdr (car minor))))
+ − 766 (if (symbol-value-in-buffer sym buffer nil)
+ − 767 (progn
+ − 768 (insert (format "Minor Mode Bindings for `%s':\n"
+ − 769 sym)
+ − 770 heading)
+ − 771 (describe-bindings-internal map nil shadow prefix mouse-only-p)
+ − 772 (insert "\n")
+ − 773 (setq shadow (cons map shadow))))
+ − 774 (setq minor (cdr minor))))
+ − 775 (if local
+ − 776 (progn
+ − 777 (insert "Local Bindings:\n" heading)
+ − 778 (describe-bindings-internal local nil shadow prefix mouse-only-p)
+ − 779 (insert "\n")
+ − 780 (setq shadow (cons local shadow))))
771
+ − 781 (if (console-on-window-system-p)
+ − 782 (progn
+ − 783 (insert "Global Window-System-Only Bindings:\n" heading)
+ − 784 (describe-bindings-internal global-window-system-map nil
+ − 785 shadow prefix mouse-only-p)
+ − 786 (push global-window-system-map shadow))
+ − 787 (insert "Global TTY-Only Bindings:\n" heading)
+ − 788 (describe-bindings-internal global-tty-map nil
+ − 789 shadow prefix mouse-only-p)
+ − 790 (push global-tty-map shadow))
+ − 791 (insert "\nGlobal Bindings:\n" heading)
428
+ − 792 (describe-bindings-internal (current-global-map)
+ − 793 nil shadow prefix mouse-only-p)
+ − 794 (when (and prefix function-key-map (not mouse-only-p))
+ − 795 (insert "\nFunction key map translations:\n" heading)
+ − 796 (describe-bindings-internal function-key-map nil nil
+ − 797 prefix mouse-only-p))
+ − 798 (set-buffer buffer)
+ − 799 standard-output))
+ − 800
+ − 801 (defun describe-prefix-bindings ()
+ − 802 "Describe the bindings of the prefix used to reach this command.
+ − 803 The prefix described consists of all but the last event
+ − 804 of the key sequence that ran this command."
+ − 805 (interactive)
+ − 806 (let* ((key (this-command-keys))
+ − 807 (prefix (make-vector (1- (length key)) nil))
+ − 808 i)
+ − 809 (setq i 0)
+ − 810 (while (< i (length prefix))
+ − 811 (aset prefix i (aref key i))
+ − 812 (setq i (1+ i)))
+ − 813 (with-displaying-help-buffer
+ − 814 (lambda ()
+ − 815 (princ "Key bindings starting with ")
+ − 816 (princ (key-description prefix))
+ − 817 (princ ":\n\n")
+ − 818 (describe-bindings-1 prefix nil))
+ − 819 (format "%s prefix" (key-description prefix)))))
+ − 820
+ − 821 ;; Make C-h after a prefix, when not specifically bound,
+ − 822 ;; run describe-prefix-bindings.
+ − 823 (setq prefix-help-command 'describe-prefix-bindings)
+ − 824
+ − 825 (defun describe-installation ()
+ − 826 "Display a buffer showing information about this XEmacs was compiled."
+ − 827 (interactive)
+ − 828 (if (and (boundp 'Installation-string)
+ − 829 (stringp Installation-string))
+ − 830 (with-displaying-help-buffer
+ − 831 (lambda ()
442
+ − 832 (princ
+ − 833 (if (fboundp 'decode-coding-string)
+ − 834 (decode-coding-string Installation-string 'automatic-conversion)
+ − 835 Installation-string)))
428
+ − 836 "Installation")
+ − 837 (error "No Installation information available.")))
+ − 838
+ − 839 (defun view-emacs-news ()
+ − 840 "Display info on recent changes to XEmacs."
+ − 841 (interactive)
2986
+ − 842 (Help-find-file (expand-file-name "NEWS" data-directory)))
428
+ − 843
3074
+ − 844 (defun view-xemacs-problems ()
+ − 845 "Display known problems with XEmacs."
+ − 846 (interactive)
+ − 847 (Help-find-file (expand-file-name "PROBLEMS" data-directory)))
+ − 848
428
+ − 849 (defun xemacs-www-page ()
+ − 850 "Go to the XEmacs World Wide Web page."
+ − 851 (interactive)
776
+ − 852 (if-fboundp 'browse-url
442
+ − 853 (browse-url "http://www.xemacs.org/")
428
+ − 854 (error "xemacs-www-page requires browse-url")))
+ − 855
+ − 856 (defun xemacs-www-faq ()
+ − 857 "View the latest and greatest XEmacs FAQ using the World Wide Web."
+ − 858 (interactive)
776
+ − 859 (if-fboundp 'browse-url
442
+ − 860 (browse-url "http://www.xemacs.org/faq/index.html")
428
+ − 861 (error "xemacs-www-faq requires browse-url")))
+ − 862
+ − 863 (defun xemacs-local-faq ()
+ − 864 "View the local copy of the XEmacs FAQ.
+ − 865 If you have access to the World Wide Web, you should use `xemacs-www-faq'
+ − 866 instead, to ensure that you get the most up-to-date information."
+ − 867 (interactive)
+ − 868 (save-window-excursion
+ − 869 (info)
+ − 870 (Info-find-node "xemacs-faq" "Top"))
+ − 871 (switch-to-buffer "*info*"))
+ − 872
462
+ − 873 (defun view-sample-init-el ()
+ − 874 "Display the sample init.el file."
+ − 875 (interactive)
+ − 876 (Help-find-file (locate-data-file "sample.init.el")))
+ − 877
428
+ − 878 (defcustom view-lossage-key-count 100
+ − 879 "*Number of keys `view-lossage' shows.
+ − 880 The maximum number of available keys is governed by `recent-keys-ring-size'."
+ − 881 :type 'integer
+ − 882 :group 'help)
+ − 883
+ − 884 (defcustom view-lossage-message-count 100
+ − 885 "*Number of minibuffer messages `view-lossage' shows."
+ − 886 :type 'integer
+ − 887 :group 'help)
+ − 888
+ − 889 (defun print-recent-messages (n)
+ − 890 "Print N most recent messages to standard-output, most recent first.
+ − 891 If N is nil, all messages will be printed."
793
+ − 892 (clear-message) ;; make sure current message goes into log
428
+ − 893 (save-excursion
+ − 894 (let ((buffer (get-buffer-create " *Message-Log*"))
+ − 895 oldpoint extent)
+ − 896 (goto-char (point-max buffer) buffer)
+ − 897 (set-buffer standard-output)
+ − 898 (while (and (not (bobp buffer))
+ − 899 (or (null n) (>= (decf n) 0)))
+ − 900 (setq oldpoint (point buffer))
+ − 901 (setq extent (extent-at oldpoint buffer
+ − 902 'message-multiline nil 'before))
+ − 903 ;; If the message was multiline, move all the way to the
+ − 904 ;; beginning.
+ − 905 (if extent
+ − 906 (goto-char (extent-start-position extent) buffer)
+ − 907 (forward-line -1 buffer))
+ − 908 (insert-buffer-substring buffer (point buffer) oldpoint)))))
+ − 909
793
+ − 910 (defun view-warnings ()
+ − 911 "Display warnings issued."
+ − 912 (interactive)
+ − 913 (with-displaying-help-buffer
+ − 914 (lambda ()
+ − 915 (let ((buf (get-buffer "*Warnings*")))
+ − 916 (when buf
+ − 917 (save-excursion
+ − 918 (set-buffer standard-output)
+ − 919 (map-extents
+ − 920 #'(lambda (extent arg)
+ − 921 (goto-char (point-min))
+ − 922 (insert (extent-string extent)))
+ − 923 buf)))))
+ − 924 "warnings"))
+ − 925
+ − 926 (defun view-lossage (&optional no-keys)
428
+ − 927 "Display recent input keystrokes and recent minibuffer messages.
+ − 928 The number of keys shown is controlled by `view-lossage-key-count'.
1038
+ − 929 The number of messages shown is controlled by `view-lossage-message-count'.
+ − 930
+ − 931 If optional arg NO-KEYS (prefix arg, interactively) is non-nil,
+ − 932 then recent input keystrokes output is omitted."
+ − 933 (interactive "P")
428
+ − 934 (with-displaying-help-buffer
+ − 935 (lambda ()
793
+ − 936 (unless no-keys
+ − 937 (princ (key-description (recent-keys view-lossage-key-count)))
+ − 938 (save-excursion
+ − 939 (set-buffer standard-output)
+ − 940 (goto-char (point-min))
+ − 941 (insert "Recent keystrokes:\n\n")
+ − 942 (while (progn (move-to-column 50) (not (eobp)))
+ − 943 (search-forward " " nil t)
+ − 944 (insert "\n")))
+ − 945 (princ "\n\n\n"))
+ − 946 ;; Copy the messages from " *Message-Log*", reversing their order and
+ − 947 ;; handling multiline messages correctly.
+ − 948 (princ "Recent minibuffer messages (most recent first):\n\n")
428
+ − 949 (print-recent-messages view-lossage-message-count))
+ − 950 "lossage"))
+ − 951
+ − 952 (define-function 'help 'help-for-help)
+ − 953
+ − 954 (make-help-screen help-for-help
+ − 955 "A B C F I K L M N P S T V W C-c C-d C-f C-i C-k C-n C-w; ? for more help:"
502
+ − 956 (concat
+ − 957 "Type a Help option:
428
+ − 958 \(Use SPC or DEL to scroll through this text. Type \\<help-map>\\[help-quit] to exit the Help command.)
+ − 959
502
+ − 960 Help on key bindings:
+ − 961
+ − 962 \\[describe-bindings] Table of all key bindings.
+ − 963 \\[describe-key-briefly] Type a key sequence or select a menu item;
+ − 964 it displays the corresponding command name.
+ − 965 \\[describe-key] Type a key sequence or select a menu item;
+ − 966 it displays the documentation for the command bound to that key.
+ − 967 (Terser but more up-to-date than what's in the manual.)
+ − 968 \\[Info-goto-emacs-key-command-node] Type a key sequence or select a menu item;
+ − 969 it jumps to the full documentation in the XEmacs User's Manual
+ − 970 for the corresponding command.
+ − 971 \\[view-lossage] Recent input keystrokes and minibuffer messages.
+ − 972 \\[describe-mode] Documentation of current major and minor modes.
+ − 973 \\[describe-pointer] Table of all mouse-button bindings.
+ − 974 \\[where-is] Type a command name; it displays which keystrokes invoke that command.
+ − 975
+ − 976 Help on functions and variables:
+ − 977
428
+ − 978 \\[hyper-apropos] Type a substring; it shows a hypertext list of
+ − 979 functions and variables that contain that substring.
502
+ − 980 \\[command-apropos] Older version of apropos; superseded by previous command.
+ − 981 \\[apropos-documentation] Type a substring; it shows a hypertext list of
+ − 982 functions and variables containing that substring anywhere
+ − 983 in their documentation.
+ − 984 \\[Info-goto-emacs-command-node] Type a command name; it jumps to the full documentation
+ − 985 in the XEmacs User's Manual.
+ − 986 \\[describe-function] Type a command or function name; it shows its documentation.
+ − 987 (Terser but more up-to-date than what's in the manual.)
+ − 988 \\[Info-elisp-ref] Type a function name; it jumps to the full documentation
+ − 989 in the XEmacs Lisp Reference Manual.
+ − 990 \\[Info-search-index-in-xemacs-and-lispref] Type a substring; it looks it up in the indices of both
+ − 991 the XEmacs User's Manual and the XEmacs Lisp Reference Manual.
+ − 992 It jumps to the first match (preferring an exact match); you
+ − 993 can use `\\<Info-mode-map>\\[Info-index-next]\\<help-map>' to successively visit other matches.
+ − 994 \\[describe-variable] Type a variable name; it displays its documentation and value.
+ − 995
+ − 996 Miscellaneous:
+ − 997
+ − 998 "
+ − 999 (if (string-match "beta" emacs-version)
+ − 1000 "\\[describe-beta] Special considerations about running a beta version of XEmacs.
+ − 1001 "
+ − 1002 "")
+ − 1003 "
3074
+ − 1004 \\[view-xemacs-problems] Known problems.
428
+ − 1005 \\[customize] Customize Emacs options.
502
+ − 1006 \\[describe-distribution] How to obtain XEmacs.
+ − 1007 \\[describe-last-error] Information about the most recent error.
428
+ − 1008 \\[xemacs-local-faq] Local copy of the XEmacs FAQ.
+ − 1009 \\[info] Info documentation reader.
+ − 1010 \\[Info-query] Type an Info file name; it displays it in Info reader.
502
+ − 1011 \\[describe-copying] XEmacs copying permission (General Public License).
428
+ − 1012 \\[view-emacs-news] News of recent XEmacs changes.
+ − 1013 \\[finder-by-keyword] Type a topic keyword; it finds matching packages.
+ − 1014 \\[describe-syntax] Contents of syntax table with explanations.
502
+ − 1015 \\[view-sample-init-el] View the sample init.el that comes with XEmacs.
428
+ − 1016 \\[help-with-tutorial] XEmacs learn-by-doing tutorial.
502
+ − 1017 \\[describe-no-warranty] Information on absence of warranty for XEmacs."
+ − 1018 )
428
+ − 1019 help-map)
+ − 1020
+ − 1021 (defun function-called-at-point ()
+ − 1022 "Return the function which is called by the list containing point.
+ − 1023 If that gives no function, return the function whose name is around point.
+ − 1024 If that doesn't give a function, return nil."
+ − 1025 (or (ignore-errors
+ − 1026 (save-excursion
+ − 1027 (save-restriction
+ − 1028 (narrow-to-region (max (point-min) (- (point) 1000))
+ − 1029 (point-max))
+ − 1030 (backward-up-list 1)
+ − 1031 (forward-char 1)
+ − 1032 (let (obj)
+ − 1033 (setq obj (read (current-buffer)))
+ − 1034 (and (symbolp obj) (fboundp obj) obj)))))
+ − 1035 (ignore-errors
+ − 1036 (with-syntax-table emacs-lisp-mode-syntax-table
+ − 1037 (save-excursion
+ − 1038 (or (not (zerop (skip-syntax-backward "_w")))
+ − 1039 (eq (char-syntax (char-after (point))) ?w)
+ − 1040 (eq (char-syntax (char-after (point))) ?_)
+ − 1041 (forward-sexp -1))
+ − 1042 (skip-chars-forward "`'")
+ − 1043 (let ((obj (read (current-buffer))))
+ − 1044 (and (symbolp obj) (fboundp obj) obj)))))))
+ − 1045
+ − 1046 (defun function-at-point ()
+ − 1047 "Return the function whose name is around point.
+ − 1048 If that gives no function, return the function which is called by the
+ − 1049 list containing point. If that doesn't give a function, return nil."
+ − 1050 (or (ignore-errors
+ − 1051 (with-syntax-table emacs-lisp-mode-syntax-table
+ − 1052 (save-excursion
+ − 1053 (or (not (zerop (skip-syntax-backward "_w")))
+ − 1054 (eq (char-syntax (char-after (point))) ?w)
+ − 1055 (eq (char-syntax (char-after (point))) ?_)
+ − 1056 (forward-sexp -1))
+ − 1057 (skip-chars-forward "`'")
+ − 1058 (let ((obj (read (current-buffer))))
+ − 1059 (and (symbolp obj) (fboundp obj) obj)))))
+ − 1060 (ignore-errors
+ − 1061 (save-excursion
+ − 1062 (save-restriction
+ − 1063 (narrow-to-region (max (point-min) (- (point) 1000))
+ − 1064 (point-max))
+ − 1065 (backward-up-list 1)
+ − 1066 (forward-char 1)
+ − 1067 (let (obj)
+ − 1068 (setq obj (read (current-buffer)))
+ − 1069 (and (symbolp obj) (fboundp obj) obj)))))))
+ − 1070
442
+ − 1071 (defun function-at-event (event)
+ − 1072 "Return the function whose name is around the position of EVENT.
+ − 1073 EVENT should be a mouse event. When calling from a popup or context menu,
+ − 1074 use `last-popup-menu-event' to find out where the mouse was clicked.
+ − 1075 \(You cannot use (interactive \"e\"), unfortunately. This returns a
+ − 1076 misc-user event.)
+ − 1077
+ − 1078 If the event contains no position, or the position is not over text, or
+ − 1079 there is no function around that point, nil is returned."
+ − 1080 (if (and event (event-buffer event) (event-point event))
+ − 1081 (save-excursion
+ − 1082 (set-buffer (event-buffer event))
+ − 1083 (goto-char (event-point event))
+ − 1084 (function-at-point))))
+ − 1085
428
+ − 1086 ;; Default to nil for the non-hackers? Not until we find a way to
+ − 1087 ;; distinguish hackers from non-hackers automatically!
+ − 1088 (defcustom describe-function-show-arglist t
+ − 1089 "*If non-nil, describe-function will show its arglist,
+ − 1090 unless the function is autoloaded."
+ − 1091 :type 'boolean
+ − 1092 :group 'help-appearance)
+ − 1093
+ − 1094 (defun describe-symbol-find-file (symbol)
+ − 1095 (loop for (file . load-data) in load-history
+ − 1096 do (when (memq symbol load-data)
+ − 1097 (return file))))
+ − 1098
+ − 1099 (define-obsolete-function-alias
+ − 1100 'describe-function-find-file
+ − 1101 'describe-symbol-find-file)
+ − 1102
+ − 1103 (defun describe-function (function)
+ − 1104 "Display the full documentation of FUNCTION (a symbol).
+ − 1105 When run interactively, it defaults to any function found by
+ − 1106 `function-at-point'."
+ − 1107 (interactive
+ − 1108 (let* ((fn (function-at-point))
+ − 1109 (val (let ((enable-recursive-minibuffers t))
+ − 1110 (completing-read
+ − 1111 (if fn
+ − 1112 (format (gettext "Describe function (default %s): ")
+ − 1113 fn)
+ − 1114 (gettext "Describe function: "))
430
+ − 1115 obarray 'fboundp t nil 'function-history
+ − 1116 (symbol-name fn)))))
+ − 1117 (list (intern val))))
428
+ − 1118 (with-displaying-help-buffer
+ − 1119 (lambda ()
+ − 1120 (describe-function-1 function)
+ − 1121 ;; Return the text we displayed.
+ − 1122 (buffer-string nil nil standard-output))
+ − 1123 (format "function `%s'" function)))
+ − 1124
+ − 1125 (defun function-obsolete-p (function)
+ − 1126 "Return non-nil if FUNCTION is obsolete."
+ − 1127 (not (null (get function 'byte-obsolete-info))))
+ − 1128
+ − 1129 (defun function-obsoleteness-doc (function)
+ − 1130 "If FUNCTION is obsolete, return a string describing this."
+ − 1131 (let ((obsolete (get function 'byte-obsolete-info)))
+ − 1132 (if obsolete
+ − 1133 (format "Obsolete; %s"
+ − 1134 (if (stringp (car obsolete))
+ − 1135 (car obsolete)
+ − 1136 (format "use `%s' instead." (car obsolete)))))))
+ − 1137
+ − 1138 (defun function-compatible-p (function)
+ − 1139 "Return non-nil if FUNCTION is present for Emacs compatibility."
+ − 1140 (not (null (get function 'byte-compatible-info))))
+ − 1141
+ − 1142 (defun function-compatibility-doc (function)
+ − 1143 "If FUNCTION is Emacs compatible, return a string describing this."
+ − 1144 (let ((compatible (get function 'byte-compatible-info)))
+ − 1145 (if compatible
+ − 1146 (format "Emacs Compatible; %s"
+ − 1147 (if (stringp (car compatible))
+ − 1148 (car compatible)
+ − 1149 (format "use `%s' instead." (car compatible)))))))
+ − 1150
+ − 1151 ;Here are all the possibilities below spelled out, for the benefit
+ − 1152 ;of the I18N3 snarfer.
+ − 1153 ;
+ − 1154 ;(gettext "a built-in function")
+ − 1155 ;(gettext "an interactive built-in function")
+ − 1156 ;(gettext "a built-in macro")
+ − 1157 ;(gettext "an interactive built-in macro")
+ − 1158 ;(gettext "a compiled Lisp function")
+ − 1159 ;(gettext "an interactive compiled Lisp function")
+ − 1160 ;(gettext "a compiled Lisp macro")
+ − 1161 ;(gettext "an interactive compiled Lisp macro")
+ − 1162 ;(gettext "a Lisp function")
+ − 1163 ;(gettext "an interactive Lisp function")
+ − 1164 ;(gettext "a Lisp macro")
+ − 1165 ;(gettext "an interactive Lisp macro")
+ − 1166 ;(gettext "a mocklisp function")
+ − 1167 ;(gettext "an interactive mocklisp function")
+ − 1168 ;(gettext "a mocklisp macro")
+ − 1169 ;(gettext "an interactive mocklisp macro")
+ − 1170 ;(gettext "an autoloaded Lisp function")
+ − 1171 ;(gettext "an interactive autoloaded Lisp function")
+ − 1172 ;(gettext "an autoloaded Lisp macro")
+ − 1173 ;(gettext "an interactive autoloaded Lisp macro")
+ − 1174
+ − 1175 ;; taken out of `describe-function-1'
+ − 1176 (defun function-arglist (function)
+ − 1177 "Return a string giving the argument list of FUNCTION.
+ − 1178 For example:
+ − 1179
+ − 1180 (function-arglist 'function-arglist)
+ − 1181 => (function-arglist FUNCTION)
+ − 1182
+ − 1183 This function is used by `describe-function-1' to list function
+ − 1184 arguments in the standard Lisp style."
440
+ − 1185 (let* ((fnc (indirect-function function))
+ − 1186 (fndef (if (eq (car-safe fnc) 'macro)
+ − 1187 (cdr fnc)
+ − 1188 fnc))
428
+ − 1189 (arglist
440
+ − 1190 (cond ((compiled-function-p fndef)
+ − 1191 (compiled-function-arglist fndef))
+ − 1192 ((eq (car-safe fndef) 'lambda)
+ − 1193 (nth 1 fndef))
+ − 1194 ((subrp fndef)
+ − 1195 (let* ((doc (documentation function))
3065
+ − 1196 (args (and doc
+ − 1197 (string-match
440
+ − 1198 "[\n\t ]*\narguments: ?(\\(.*\\))\n?\\'"
+ − 1199 doc)
+ − 1200 (match-string 1 doc))))
+ − 1201 ;; If there are no arguments documented for the
+ − 1202 ;; subr, rather don't print anything.
+ − 1203 (cond ((null args) t)
+ − 1204 ((equal args "") nil)
+ − 1205 (args))))
+ − 1206 (t t))))
428
+ − 1207 (cond ((listp arglist)
+ − 1208 (prin1-to-string
+ − 1209 (cons function (mapcar (lambda (arg)
+ − 1210 (if (memq arg '(&optional &rest))
+ − 1211 arg
+ − 1212 (intern (upcase (symbol-name arg)))))
+ − 1213 arglist))
+ − 1214 t))
+ − 1215 ((stringp arglist)
+ − 1216 (format "(%s %s)" function arglist)))))
+ − 1217
+ − 1218 (defun function-documentation (function &optional strip-arglist)
+ − 1219 "Return a string giving the documentation for FUNCTION, if any.
+ − 1220 If the optional argument STRIP-ARGLIST is non-nil, remove the arglist
+ − 1221 part of the documentation of internal subroutines."
+ − 1222 (let ((doc (condition-case nil
+ − 1223 (or (documentation function)
+ − 1224 (gettext "not documented"))
2275
+ − 1225 (void-function "(alias for undefined function)")
+ − 1226 (error "(unexpected error from `documention')"))))
428
+ − 1227 (if (and strip-arglist
+ − 1228 (string-match "[\n\t ]*\narguments: ?(\\(.*\\))\n?\\'" doc))
+ − 1229 (setq doc (substring doc 0 (match-beginning 0))))
+ − 1230 doc))
442
+ − 1231
462
+ − 1232 ;; replacement for `princ' that puts the text in the specified face,
+ − 1233 ;; if possible
+ − 1234 (defun Help-princ-face (object face)
+ − 1235 (cond ((bufferp standard-output)
464
+ − 1236 (let ((opoint (point standard-output)))
+ − 1237 (princ object)
+ − 1238 (put-nonduplicable-text-property opoint (point standard-output)
+ − 1239 'face face standard-output)))
+ − 1240 ((markerp standard-output)
+ − 1241 (let ((buf (marker-buffer standard-output))
+ − 1242 (pos (marker-position standard-output)))
+ − 1243 (princ object)
+ − 1244 (put-nonduplicable-text-property
+ − 1245 pos (marker-position standard-output) 'face face buf)))
1779
+ − 1246 (t (princ object))))
462
+ − 1247
+ − 1248 ;; replacement for `prin1' that puts the text in the specified face,
+ − 1249 ;; if possible
+ − 1250 (defun Help-prin1-face (object face)
+ − 1251 (cond ((bufferp standard-output)
464
+ − 1252 (let ((opoint (point standard-output)))
+ − 1253 (prin1 object)
+ − 1254 (put-nonduplicable-text-property opoint (point standard-output)
+ − 1255 'face face standard-output)))
+ − 1256 ((markerp standard-output)
+ − 1257 (let ((buf (marker-buffer standard-output))
+ − 1258 (pos (marker-position standard-output)))
+ − 1259 (prin1 object)
+ − 1260 (put-nonduplicable-text-property
+ − 1261 pos (marker-position standard-output) 'face face buf)))
1779
+ − 1262 (t (prin1 object))))
462
+ − 1263
442
+ − 1264 (defvar help-symbol-regexp
+ − 1265 (let ((sym-char "[+a-zA-Z0-9_:*]")
+ − 1266 (sym-char-no-dash "[-+a-zA-Z0-9_:*]"))
+ − 1267 (concat "\\("
+ − 1268 ;; a symbol with a - in it.
+ − 1269 "\\<\\(" sym-char-no-dash "+\\(-" sym-char-no-dash "+\\)+\\)\\>"
+ − 1270 "\\|"
+ − 1271 "`\\(" sym-char "+\\)'"
+ − 1272 "\\)")))
+ − 1273
+ − 1274 (defun help-symbol-run-function-1 (ev ex fun)
+ − 1275 (let ((help-sticky-window
+ − 1276 ;; if we were called from a help buffer, make sure the new help
+ − 1277 ;; goes in the same window.
+ − 1278 (if (and (event-buffer ev)
+ − 1279 (symbol-value-in-buffer 'help-window-config
+ − 1280 (event-buffer ev)))
+ − 1281 (event-window ev)
+ − 1282 help-sticky-window)))
+ − 1283 (funcall fun (extent-property ex 'help-symbol))))
+ − 1284
+ − 1285 (defun help-symbol-run-function (fun)
+ − 1286 (let ((ex (extent-at-event last-popup-menu-event 'help-symbol)))
+ − 1287 (when ex
+ − 1288 (help-symbol-run-function-1 last-popup-menu-event ex fun))))
+ − 1289
+ − 1290 (defvar help-symbol-function-context-menu
462
+ − 1291 '(["View %_Documentation" (help-symbol-run-function 'describe-function)]
442
+ − 1292 ["Find %_Function Source" (help-symbol-run-function 'find-function)]
462
+ − 1293 ["Find %_Tag" (help-symbol-run-function 'find-tag)]
442
+ − 1294 ))
+ − 1295
+ − 1296 (defvar help-symbol-variable-context-menu
462
+ − 1297 '(["View %_Documentation" (help-symbol-run-function 'describe-variable)]
442
+ − 1298 ["Find %_Variable Source" (help-symbol-run-function 'find-variable)]
462
+ − 1299 ["Find %_Tag" (help-symbol-run-function 'find-tag)]
442
+ − 1300 ))
+ − 1301
+ − 1302 (defvar help-symbol-function-and-variable-context-menu
462
+ − 1303 '(["View Function %_Documentation" (help-symbol-run-function
442
+ − 1304 'describe-function)]
+ − 1305 ["View Variable D%_ocumentation" (help-symbol-run-function
+ − 1306 'describe-variable)]
+ − 1307 ["Find %_Function Source" (help-symbol-run-function 'find-function)]
+ − 1308 ["Find %_Variable Source" (help-symbol-run-function 'find-variable)]
462
+ − 1309 ["Find %_Tag" (help-symbol-run-function 'find-tag)]
442
+ − 1310 ))
+ − 1311
+ − 1312 (defun frob-help-extents (buffer)
+ − 1313 ;; Look through BUFFER, starting at the buffer's point and continuing
+ − 1314 ;; till end of file, and find documented functions and variables.
+ − 1315 ;; any such symbol found is tagged with an extent, that sets up these
+ − 1316 ;; properties:
+ − 1317 ;; 1. mouse-face is 'highlight (so the extent gets highlighted on mouse over)
+ − 1318 ;; 2. help-symbol is the name of the symbol.
464
+ − 1319 ;; 3. face is 'hyper-apropos-hyperlink.
462
+ − 1320 ;; 4. context-menu is a list of context menu items, specific to whether
442
+ − 1321 ;; the symbol is a function, variable, or both.
462
+ − 1322 ;; 5. activate-function will cause the function or variable to be described,
442
+ − 1323 ;; replacing the existing help contents.
+ − 1324 (save-excursion
+ − 1325 (set-buffer buffer)
+ − 1326 (let (b e name)
+ − 1327 (while (re-search-forward help-symbol-regexp nil t)
+ − 1328 (setq b (or (match-beginning 2) (match-beginning 4)))
+ − 1329 (setq e (or (match-end 2) (match-end 4)))
+ − 1330 (setq name (buffer-substring b e))
+ − 1331 (let* ((sym (intern-soft name))
+ − 1332 (var (and sym (boundp sym)
+ − 1333 (documentation-property sym
+ − 1334 'variable-documentation t)))
+ − 1335 (fun (and sym (fboundp sym)
2275
+ − 1336 (condition-case nil
+ − 1337 (documentation sym t)
+ − 1338 (void-function "(alias for undefined function)")
+ − 1339 (error "(unexpected error from `documention')")))))
442
+ − 1340 (when (or var fun)
+ − 1341 (let ((ex (make-extent b e)))
622
+ − 1342 (require 'hyper-apropos)
442
+ − 1343 (set-extent-property ex 'mouse-face 'highlight)
+ − 1344 (set-extent-property ex 'help-symbol sym)
464
+ − 1345 (set-extent-property ex 'face 'hyper-apropos-hyperlink)
442
+ − 1346 (set-extent-property
+ − 1347 ex 'context-menu
+ − 1348 (cond ((and var fun)
+ − 1349 help-symbol-function-and-variable-context-menu)
+ − 1350 (var help-symbol-variable-context-menu)
+ − 1351 (fun help-symbol-function-context-menu)))
+ − 1352 (set-extent-property
+ − 1353 ex 'activate-function
+ − 1354 (if fun
+ − 1355 #'(lambda (ev ex)
+ − 1356 (help-symbol-run-function-1 ev ex 'describe-function))
+ − 1357 #'(lambda (ev ex)
+ − 1358 (help-symbol-run-function-1 ev ex 'describe-variable))))
+ − 1359 ))))))) ;; 11 parentheses!
428
+ − 1360
+ − 1361 (defun describe-function-1 (function &optional nodoc)
+ − 1362 "This function does the work for `describe-function'."
462
+ − 1363 (princ "`")
+ − 1364 ;; (Help-princ-face function 'font-lock-function-name-face) overkill
+ − 1365 (princ function)
+ − 1366 (princ "' is ")
428
+ − 1367 (let* ((def function)
+ − 1368 aliases file-name autoload-file kbd-macro-p fndef macrop)
+ − 1369 (while (and (symbolp def) (fboundp def))
+ − 1370 (when (not (eq def function))
+ − 1371 (setq aliases
+ − 1372 (if aliases
+ − 1373 ;; I18N3 Need gettext due to concat
+ − 1374 (concat aliases
+ − 1375 (format
+ − 1376 "\n which is an alias for `%s', "
+ − 1377 (symbol-name def)))
+ − 1378 (format "an alias for `%s', " (symbol-name def)))))
+ − 1379 (setq def (symbol-function def)))
+ − 1380 (if (and (fboundp 'compiled-function-annotation)
+ − 1381 (compiled-function-p def))
502
+ − 1382 (setq file-name (declare-fboundp (compiled-function-annotation def))))
428
+ − 1383 (if (eq 'macro (car-safe def))
+ − 1384 (setq fndef (cdr def)
+ − 1385 file-name (and (compiled-function-p (cdr def))
+ − 1386 (fboundp 'compiled-function-annotation)
502
+ − 1387 (declare-fboundp
+ − 1388 (compiled-function-annotation (cdr def))))
428
+ − 1389 macrop t)
+ − 1390 (setq fndef def))
+ − 1391 (if aliases (princ aliases))
+ − 1392 (let ((int #'(lambda (string an-p macro-p)
+ − 1393 (princ (format
+ − 1394 (gettext (concat
+ − 1395 (cond ((commandp def)
+ − 1396 "an interactive ")
+ − 1397 (an-p "an ")
+ − 1398 (t "a "))
+ − 1399 "%s"
+ − 1400 (if macro-p " macro" " function")))
+ − 1401 string)))))
+ − 1402 (cond ((or (stringp def) (vectorp def))
+ − 1403 (princ "a keyboard macro.")
+ − 1404 (setq kbd-macro-p t))
+ − 1405 ((subrp fndef)
+ − 1406 (funcall int "built-in" nil macrop))
+ − 1407 ((compiled-function-p fndef)
+ − 1408 (funcall int "compiled Lisp" nil macrop))
+ − 1409 ((eq (car-safe fndef) 'lambda)
+ − 1410 (funcall int "Lisp" nil macrop))
+ − 1411 ((eq (car-safe fndef) 'mocklisp)
+ − 1412 (funcall int "mocklisp" nil macrop))
+ − 1413 ((eq (car-safe def) 'autoload)
+ − 1414 (setq autoload-file (elt def 1))
+ − 1415 (funcall int "autoloaded Lisp" t (elt def 4)))
+ − 1416 ((and (symbolp def) (not (fboundp def)))
+ − 1417 (princ "a symbol with a void (unbound) function definition."))
+ − 1418 (t
+ − 1419 nil)))
+ − 1420 (princ "\n")
+ − 1421 (if autoload-file
+ − 1422 (princ (format " -- autoloads from \"%s\"\n" autoload-file)))
+ − 1423 (or file-name
+ − 1424 (setq file-name (describe-symbol-find-file function)))
+ − 1425 (if file-name
+ − 1426 (princ (format " -- loaded from \"%s\"\n" file-name)))
+ − 1427 ;; (terpri)
+ − 1428 (if describe-function-show-arglist
+ − 1429 (let ((arglist (function-arglist function)))
+ − 1430 (when arglist
464
+ − 1431 (require 'hyper-apropos)
+ − 1432 (Help-princ-face arglist 'hyper-apropos-documentation)
428
+ − 1433 (terpri))))
+ − 1434 (terpri)
+ − 1435 (cond (kbd-macro-p
+ − 1436 (princ "These characters are executed:\n\n\t")
+ − 1437 (princ (key-description def))
+ − 1438 (cond ((setq def (key-binding def))
+ − 1439 (princ (format "\n\nwhich executes the command `%s'.\n\n"
+ − 1440 def))
+ − 1441 (describe-function-1 def))))
+ − 1442 (nodoc nil)
+ − 1443 (t
+ − 1444 ;; tell the user about obsoleteness.
+ − 1445 ;; If the function is obsolete and is aliased, don't
+ − 1446 ;; even bother to report the documentation, as a further
+ − 1447 ;; encouragement to use the new function.
+ − 1448 (let ((obsolete (function-obsoleteness-doc function))
+ − 1449 (compatible (function-compatibility-doc function)))
+ − 1450 (when obsolete
+ − 1451 (princ obsolete)
+ − 1452 (terpri)
+ − 1453 (terpri))
+ − 1454 (when compatible
+ − 1455 (princ compatible)
+ − 1456 (terpri)
+ − 1457 (terpri))
+ − 1458 (unless (and obsolete aliases)
+ − 1459 (let ((doc (function-documentation function t)))
+ − 1460 (princ "Documentation:\n")
442
+ − 1461 (let ((oldp (point standard-output))
+ − 1462 newp)
+ − 1463 (princ doc)
+ − 1464 (setq newp (point standard-output))
+ − 1465 (goto-char oldp standard-output)
+ − 1466 (frob-help-extents standard-output)
+ − 1467 (goto-char newp standard-output))
428
+ − 1468 (unless (or (equal doc "")
+ − 1469 (eq ?\n (aref doc (1- (length doc)))))
+ − 1470 (terpri)))))))))
+ − 1471
+ − 1472
+ − 1473 ;;; [Obnoxious, whining people who complain very LOUDLY on Usenet
+ − 1474 ;;; are binding this to keys.]
+ − 1475 (defun describe-function-arglist (function)
+ − 1476 (interactive (list (or (function-at-point)
+ − 1477 (error "no function call at point"))))
+ − 1478 (message nil)
+ − 1479 (message (function-arglist function)))
+ − 1480
+ − 1481 (defun variable-at-point ()
+ − 1482 (ignore-errors
+ − 1483 (with-syntax-table emacs-lisp-mode-syntax-table
+ − 1484 (save-excursion
+ − 1485 (or (not (zerop (skip-syntax-backward "_w")))
+ − 1486 (eq (char-syntax (char-after (point))) ?w)
+ − 1487 (eq (char-syntax (char-after (point))) ?_)
+ − 1488 (forward-sexp -1))
+ − 1489 (skip-chars-forward "'")
+ − 1490 (let ((obj (read (current-buffer))))
+ − 1491 (and (symbolp obj) (boundp obj) obj))))))
+ − 1492
442
+ − 1493 (defun variable-at-event (event)
+ − 1494 "Return the variable whose name is around the position of EVENT.
+ − 1495 EVENT should be a mouse event. When calling from a popup or context menu,
+ − 1496 use `last-popup-menu-event' to find out where the mouse was clicked.
+ − 1497 \(You cannot use (interactive \"e\"), unfortunately. This returns a
+ − 1498 misc-user event.)
+ − 1499
+ − 1500 If the event contains no position, or the position is not over text, or
+ − 1501 there is no variable around that point, nil is returned."
+ − 1502 (if (and event (event-buffer event) (event-point event))
+ − 1503 (save-excursion
+ − 1504 (set-buffer (event-buffer event))
+ − 1505 (goto-char (event-point event))
+ − 1506 (variable-at-point))))
+ − 1507
428
+ − 1508 (defun variable-obsolete-p (variable)
+ − 1509 "Return non-nil if VARIABLE is obsolete."
+ − 1510 (not (null (get variable 'byte-obsolete-variable))))
+ − 1511
+ − 1512 (defun variable-obsoleteness-doc (variable)
+ − 1513 "If VARIABLE is obsolete, return a string describing this."
+ − 1514 (let ((obsolete (get variable 'byte-obsolete-variable)))
+ − 1515 (if obsolete
+ − 1516 (format "Obsolete; %s"
+ − 1517 (if (stringp obsolete)
+ − 1518 obsolete
+ − 1519 (format "use `%s' instead." obsolete))))))
+ − 1520
+ − 1521 (defun variable-compatible-p (variable)
+ − 1522 "Return non-nil if VARIABLE is Emacs compatible."
+ − 1523 (not (null (get variable 'byte-compatible-variable))))
+ − 1524
+ − 1525 (defun variable-compatibility-doc (variable)
+ − 1526 "If VARIABLE is Emacs compatible, return a string describing this."
+ − 1527 (let ((compatible (get variable 'byte-compatible-variable)))
+ − 1528 (if compatible
+ − 1529 (format "Emacs Compatible; %s"
+ − 1530 (if (stringp compatible)
+ − 1531 compatible
+ − 1532 (format "use `%s' instead." compatible))))))
+ − 1533
+ − 1534 (defun built-in-variable-doc (variable)
+ − 1535 "Return a string describing whether VARIABLE is built-in."
+ − 1536 (let ((type (built-in-variable-type variable)))
+ − 1537 (case type
+ − 1538 (integer "a built-in integer variable")
+ − 1539 (const-integer "a built-in constant integer variable")
+ − 1540 (boolean "a built-in boolean variable")
+ − 1541 (const-boolean "a built-in constant boolean variable")
+ − 1542 (object "a simple built-in variable")
+ − 1543 (const-object "a simple built-in constant variable")
+ − 1544 (const-specifier "a built-in constant specifier variable")
+ − 1545 (current-buffer "a built-in buffer-local variable")
+ − 1546 (const-current-buffer "a built-in constant buffer-local variable")
+ − 1547 (default-buffer "a built-in default buffer-local variable")
+ − 1548 (selected-console "a built-in console-local variable")
+ − 1549 (const-selected-console "a built-in constant console-local variable")
+ − 1550 (default-console "a built-in default console-local variable")
+ − 1551 (t
+ − 1552 (if type "an unknown type of built-in variable?"
+ − 1553 "a variable declared in Lisp")))))
+ − 1554
+ − 1555 (defun describe-variable (variable)
+ − 1556 "Display the full documentation of VARIABLE (a symbol)."
+ − 1557 (interactive
+ − 1558 (let* ((v (variable-at-point))
+ − 1559 (val (let ((enable-recursive-minibuffers t))
+ − 1560 (completing-read
+ − 1561 (if v
+ − 1562 (format "Describe variable (default %s): " v)
+ − 1563 (gettext "Describe variable: "))
430
+ − 1564 obarray 'boundp t nil 'variable-history
+ − 1565 (symbol-name v)))))
+ − 1566 (list (intern val))))
428
+ − 1567 (with-displaying-help-buffer
+ − 1568 (lambda ()
+ − 1569 (let ((origvar variable)
+ − 1570 aliases)
+ − 1571 (let ((print-escape-newlines t))
462
+ − 1572 (princ "`")
+ − 1573 ;; (Help-princ-face (symbol-name variable)
502
+ − 1574 ;; 'font-lock-variable-name-face) overkill
462
+ − 1575 (princ (symbol-name variable))
+ − 1576 (princ "' is ")
428
+ − 1577 (while (variable-alias variable)
+ − 1578 (let ((newvar (variable-alias variable)))
+ − 1579 (if aliases
+ − 1580 ;; I18N3 Need gettext due to concat
+ − 1581 (setq aliases
+ − 1582 (concat aliases
+ − 1583 (format "\n which is an alias for `%s',"
+ − 1584 (symbol-name newvar))))
+ − 1585 (setq aliases
+ − 1586 (format "an alias for `%s',"
+ − 1587 (symbol-name newvar))))
+ − 1588 (setq variable newvar)))
+ − 1589 (if aliases
+ − 1590 (princ (format "%s" aliases)))
+ − 1591 (princ (built-in-variable-doc variable))
+ − 1592 (princ ".\n")
+ − 1593 (let ((file-name (describe-symbol-find-file variable)))
+ − 1594 (if file-name
+ − 1595 (princ (format " -- loaded from \"%s\"\n" file-name))))
+ − 1596 (princ "\nValue: ")
464
+ − 1597 (require 'hyper-apropos)
+ − 1598 (if (not (boundp variable))
+ − 1599 (Help-princ-face "void\n" 'hyper-apropos-documentation)
+ − 1600 (Help-prin1-face (symbol-value variable)
+ − 1601 'hyper-apropos-documentation)
428
+ − 1602 (terpri))
+ − 1603 (terpri)
+ − 1604 (cond ((local-variable-p variable (current-buffer))
+ − 1605 (let* ((void (cons nil nil))
+ − 1606 (def (condition-case nil
+ − 1607 (default-value variable)
+ − 1608 (error void))))
+ − 1609 (princ "This value is specific to the current buffer.\n")
+ − 1610 (if (local-variable-p variable nil)
+ − 1611 (princ "(Its value is local to each buffer.)\n"))
+ − 1612 (terpri)
+ − 1613 (if (if (eq def void)
+ − 1614 (boundp variable)
+ − 1615 (not (eq (symbol-value variable) def)))
+ − 1616 ;; #### I18N3 doesn't localize properly!
+ − 1617 (progn (princ "Default-value: ")
+ − 1618 (if (eq def void)
+ − 1619 (princ "void\n")
+ − 1620 (prin1 def)
+ − 1621 (terpri))
+ − 1622 (terpri)))))
+ − 1623 ((local-variable-p variable (current-buffer) t)
+ − 1624 (princ "Setting it would make its value buffer-local.\n\n"))))
+ − 1625 (princ "Documentation:")
+ − 1626 (terpri)
+ − 1627 (let ((doc (documentation-property variable 'variable-documentation))
+ − 1628 (obsolete (variable-obsoleteness-doc origvar))
+ − 1629 (compatible (variable-compatibility-doc origvar)))
+ − 1630 (when obsolete
+ − 1631 (princ obsolete)
+ − 1632 (terpri)
+ − 1633 (terpri))
+ − 1634 (when compatible
+ − 1635 (princ compatible)
+ − 1636 (terpri)
+ − 1637 (terpri))
+ − 1638 ;; don't bother to print anything if variable is obsolete and aliased.
+ − 1639 (when (or (not obsolete) (not aliases))
+ − 1640 (if doc
+ − 1641 ;; note: documentation-property calls substitute-command-keys.
442
+ − 1642 (let ((oldp (point standard-output))
+ − 1643 newp)
+ − 1644 (princ doc)
+ − 1645 (setq newp (point standard-output))
+ − 1646 (goto-char oldp standard-output)
+ − 1647 (frob-help-extents standard-output)
+ − 1648 (goto-char newp standard-output))
428
+ − 1649 (princ "not documented as a variable."))))
+ − 1650 (terpri)))
+ − 1651 (format "variable `%s'" variable)))
+ − 1652
+ − 1653 (defun sorted-key-descriptions (keys &optional separator)
+ − 1654 "Sort and separate the key descriptions for KEYS.
+ − 1655 The sorting is done by length (shortest bindings first), and the bindings
+ − 1656 are separated with SEPARATOR (\", \" by default)."
+ − 1657 (mapconcat 'key-description
+ − 1658 (sort keys #'(lambda (x y)
+ − 1659 (< (length x) (length y))))
+ − 1660 (or separator ", ")))
+ − 1661
+ − 1662 (defun where-is (definition &optional insert)
+ − 1663 "Print message listing key sequences that invoke specified command.
+ − 1664 Argument is a command definition, usually a symbol with a function definition.
+ − 1665 When run interactively, it defaults to any function found by
+ − 1666 `function-at-point'.
+ − 1667 If INSERT (the prefix arg) is non-nil, insert the message in the buffer."
+ − 1668 (interactive
+ − 1669 (let ((fn (function-at-point))
+ − 1670 (enable-recursive-minibuffers t)
+ − 1671 val)
+ − 1672 (setq val (read-command
+ − 1673 (if fn (format "Where is command (default %s): " fn)
456
+ − 1674 "Where is command: ")
+ − 1675 (and fn (symbol-name fn))))
428
+ − 1676 (list (if (equal (symbol-name val) "")
+ − 1677 fn val)
+ − 1678 current-prefix-arg)))
+ − 1679 (let ((keys (where-is-internal definition)))
+ − 1680 (if keys
+ − 1681 (if insert
+ − 1682 (princ (format "%s (%s)" (sorted-key-descriptions keys)
+ − 1683 definition) (current-buffer))
+ − 1684 (message "%s is on %s" definition (sorted-key-descriptions keys)))
+ − 1685 (if insert
+ − 1686 (princ (format (if (commandp definition) "M-x %s RET"
+ − 1687 "M-: (%s ...)") definition) (current-buffer))
+ − 1688 (message "%s is not on any keys" definition))))
+ − 1689 nil)
+ − 1690
+ − 1691 ;; `locate-library' moved to "packages.el"
+ − 1692
+ − 1693
+ − 1694 ;; Functions ported from C into Lisp in XEmacs
+ − 1695
+ − 1696 (defun describe-syntax ()
+ − 1697 "Describe the syntax specifications in the syntax table.
+ − 1698 The descriptions are inserted in a buffer, which is then displayed."
+ − 1699 (interactive)
+ − 1700 (with-displaying-help-buffer
+ − 1701 (lambda ()
+ − 1702 ;; defined in syntax.el
+ − 1703 (describe-syntax-table (syntax-table) standard-output))
+ − 1704 (format "syntax-table for %s" major-mode)))
+ − 1705
+ − 1706 (defun list-processes ()
+ − 1707 "Display a list of all processes.
+ − 1708 \(Any processes listed as Exited or Signaled are actually eliminated
+ − 1709 after the listing is made.)"
+ − 1710 (interactive)
+ − 1711 (with-output-to-temp-buffer "*Process List*"
+ − 1712 (set-buffer standard-output)
+ − 1713 (buffer-disable-undo standard-output)
+ − 1714 (make-local-variable 'truncate-lines)
+ − 1715 (setq truncate-lines t)
+ − 1716 ;; 00000000001111111111222222222233333333334444444444
+ − 1717 ;; 01234567890123456789012345678901234567890123456789
+ − 1718 ;; rewritten for I18N3. This one should stay rewritten
+ − 1719 ;; so that the dashes will line up properly.
+ − 1720 (princ "Proc Status Buffer Tty Command\n---- ------ ------ --- -------\n")
+ − 1721 (let ((tail (process-list)))
+ − 1722 (while tail
+ − 1723 (let* ((p (car tail))
+ − 1724 (pid (process-id p))
+ − 1725 (s (process-status p)))
+ − 1726 (setq tail (cdr tail))
+ − 1727 (princ (format "%-13s" (process-name p)))
+ − 1728 (princ s)
+ − 1729 (if (and (eq s 'exit) (/= (process-exit-status p) 0))
+ − 1730 (princ (format " %d" (process-exit-status p))))
+ − 1731 (if (memq s '(signal exit closed))
+ − 1732 ;; Do delete-exited-processes' work
+ − 1733 (delete-process p))
+ − 1734 (indent-to 22 1) ;####
+ − 1735 (let ((b (process-buffer p)))
+ − 1736 (cond ((not b)
+ − 1737 (princ "(none)"))
+ − 1738 ((not (buffer-name b))
+ − 1739 (princ "(killed)"))
+ − 1740 (t
+ − 1741 (princ (buffer-name b)))))
+ − 1742 (indent-to 37 1) ;####
+ − 1743 (let ((tn (process-tty-name p)))
+ − 1744 (cond ((not tn)
+ − 1745 (princ "(none)"))
+ − 1746 (t
+ − 1747 (princ (format "%s" tn)))))
+ − 1748 (indent-to 49 1) ;####
+ − 1749 (if (not (integerp pid))
+ − 1750 (progn
+ − 1751 (princ "network stream connection ")
+ − 1752 (princ (car pid))
+ − 1753 (princ "@")
+ − 1754 (princ (cdr pid)))
+ − 1755 (let ((cmd (process-command p)))
+ − 1756 (while cmd
+ − 1757 (princ (car cmd))
+ − 1758 (setq cmd (cdr cmd))
+ − 1759 (if cmd (princ " ")))))
+ − 1760 (terpri))))))
+ − 1761
440
+ − 1762 ;; Stop gap for 21.0 until we do help-char etc properly.
428
+ − 1763 (defun help-keymap-with-help-key (keymap form)
+ − 1764 "Return a copy of KEYMAP with an help-key binding according to help-char
+ − 1765 invoking FORM like help-form. An existing binding is not overridden.
+ − 1766 If FORM is nil then no binding is made."
+ − 1767 (let ((map (copy-keymap keymap))
+ − 1768 (key (if (characterp help-char)
+ − 1769 (vector (character-to-event help-char))
+ − 1770 help-char)))
+ − 1771 (when (and form key (not (lookup-key map key)))
+ − 1772 (define-key map key
+ − 1773 `(lambda () (interactive) (help-print-help-form ,form))))
+ − 1774 map))
+ − 1775
+ − 1776 (defun help-print-help-form (form)
+ − 1777 (let ((string (eval form)))
+ − 1778 (if (stringp string)
+ − 1779 (with-displaying-help-buffer
+ − 1780 (insert string)))))
+ − 1781
+ − 1782 ;;; help.el ends here