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