0
+ − 1 ;;; help.el --- help commands for XEmacs.
+ − 2 ;; Copyright (C) 1985, 1986, 1992, 1993, 1994 Free Software Foundation, Inc.
+ − 3
+ − 4 ;; Maintainer: FSF
+ − 5 ;; Keywords: help, internal
+ − 6
+ − 7 ;; This file is part of XEmacs.
+ − 8
+ − 9 ;; XEmacs is free software; you can redistribute it and/or modify it
+ − 10 ;; under the terms of the GNU General Public License as published by
+ − 11 ;; the Free Software Foundation; either version 2, or (at your option)
+ − 12 ;; any later version.
+ − 13
+ − 14 ;; XEmacs is distributed in the hope that it will be useful, but
+ − 15 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
+ − 16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ − 17 ;; General Public License for more details.
+ − 18
+ − 19 ;; You should have received a copy of the GNU General Public License
16
+ − 20 ;; along with XEmacs; see the file COPYING. If not, write to the
70
+ − 21 ;; Free Software Foundation, 59 Temple Place - Suite 330,
16
+ − 22 ;; Boston, MA 02111-1307, USA.
0
+ − 23
+ − 24 ;;; Synched up with: FSF 19.30.
+ − 25
+ − 26 ;;; Commentary:
+ − 27
+ − 28 ;; This code implements XEmacs's on-line help system, the one invoked by
+ − 29 ;;`M-x help-for-help'.
+ − 30
+ − 31 ;;; Code:
+ − 32
+ − 33 ;#### FSFmacs
+ − 34 ;; Get the macro make-help-screen when this is compiled,
+ − 35 ;; or run interpreted, but not when the compiled code is loaded.
+ − 36 ;(eval-when-compile (require 'help-macro))
+ − 37
120
+ − 38 (defgroup help-appearance nil
+ − 39 "Appearance of help buffers"
+ − 40 :group 'help)
+ − 41
0
+ − 42 (defvar help-map (let ((map (make-sparse-keymap)))
+ − 43 (set-keymap-name map 'help-map)
+ − 44 (set-keymap-prompt
+ − 45 map (purecopy (gettext "(Type ? for further options)")))
+ − 46 map)
+ − 47 "Keymap for characters following the Help key.")
+ − 48
+ − 49 ;; global-map definitions moved to keydefs.el
+ − 50 (fset 'help-command help-map)
+ − 51
98
+ − 52 (define-key help-map (vector help-char) 'help-for-help)
0
+ − 53 (define-key help-map "?" 'help-for-help)
+ − 54 (define-key help-map 'help 'help-for-help)
+ − 55
+ − 56 (define-key help-map "\C-l" 'describe-copying) ; on \C-c in FSFmacs
+ − 57 (define-key help-map "\C-d" 'describe-distribution)
+ − 58 (define-key help-map "\C-w" 'describe-no-warranty)
+ − 59 (define-key help-map "a" 'hyper-apropos) ; 'command-apropos in FSFmacs
+ − 60 (define-key help-map "A" 'command-apropos)
+ − 61
+ − 62 (define-key help-map "b" 'describe-bindings)
108
+ − 63 (define-key help-map "B" 'describe-beta)
0
+ − 64 (define-key help-map "\C-p" 'describe-pointer)
+ − 65
+ − 66 (define-key help-map "c" 'describe-key-briefly)
+ − 67 (define-key help-map "k" 'describe-key)
+ − 68
+ − 69 (define-key help-map "d" 'describe-function)
+ − 70 (define-key help-map "e" 'describe-last-error)
+ − 71 (define-key help-map "f" 'describe-function)
+ − 72
+ − 73 (define-key help-map "F" 'xemacs-local-faq)
+ − 74
+ − 75 ;;; Setup so Hyperbole can be autoloaded from a key.
+ − 76 ;;; Choose a key on which to place the Hyperbole menus.
+ − 77 ;;; For most people this key binding will work and will be equivalent
+ − 78 ;;; to {C-h h}.
+ − 79 ;;;
+ − 80 (or (where-is-internal 'hyperbole)
+ − 81 (where-is-internal 'hui:menu)
+ − 82 (define-key help-map "h" 'hyperbole))
+ − 83 (autoload 'hyperbole "hsite" "Hyperbole info manager menus." t)
+ − 84
+ − 85 (define-key help-map "i" 'info)
+ − 86 (define-key help-map '(control i) 'Info-query)
+ − 87 ;; FSFmacs has Info-goto-emacs-command-node on C-f, no binding
+ − 88 ;; for Info-elisp-ref
+ − 89 (define-key help-map '(control c) 'Info-goto-emacs-command-node)
+ − 90 (define-key help-map '(control k) 'Info-goto-emacs-key-command-node)
+ − 91 (define-key help-map '(control f) 'Info-elisp-ref)
+ − 92
+ − 93 (define-key help-map "l" 'view-lossage)
+ − 94
+ − 95 (define-key help-map "m" 'describe-mode)
+ − 96
+ − 97 (define-key help-map "\C-n" 'view-emacs-news)
+ − 98 (define-key help-map "n" 'view-emacs-news)
+ − 99
+ − 100 (define-key help-map "p" 'finder-by-keyword)
+ − 101 (autoload 'finder-by-keyword "finder"
+ − 102 "Find packages matching a given keyword." t)
+ − 103
+ − 104 (define-key help-map "s" 'describe-syntax)
+ − 105
+ − 106 (define-key help-map "t" 'help-with-tutorial)
+ − 107
+ − 108 (define-key help-map "w" 'where-is)
+ − 109
+ − 110 (define-key help-map "v" 'describe-variable)
+ − 111
+ − 112 (if (fboundp 'view-last-error)
+ − 113 (define-key help-map "e" 'view-last-error))
+ − 114
+ − 115
+ − 116 (define-key help-map "q" 'help-quit)
+ − 117
+ − 118 ;#### This stuff was an attempt to have font locking and hyperlinks in the
+ − 119 ;help buffer, but it doesn't really work. Some of this stuff comes from
+ − 120 ;FSF Emacs; but the FSF Emacs implementation is rather broken, as usual.
+ − 121 ;What needs to happen is this:
+ − 122 ;
+ − 123 ; -- we probably need a "hyperlink mode" from which help-mode is derived.
+ − 124 ; -- this means we probably need multiple inheritance of modes!
+ − 125 ; Thankfully this is not hard to implement; we already have the
+ − 126 ; ability for a keymap to have multiple parents. However, we'd
+ − 127 ; have to define any multiply-inherited-from modes using a standard
+ − 128 ; `define-mode' construction instead of manually doing it, because
+ − 129 ; we don't want each guy calling `kill-all-local-variables' and
+ − 130 ; messing up the previous one.
+ − 131 ; -- we need to scan the buffer ourselves (not from font-lock, because
+ − 132 ; the user might not have font-lock enabled) and highlight only
+ − 133 ; those words that are *documented* functions and variables (and
+ − 134 ; probably excluding words without dashes in them unless enclosed
+ − 135 ; in quotes, so that common words like "list" and "point" don't
+ − 136 ; become hyperlinks.
+ − 137 ; -- we should *not* use font-lock keywords like below. Instead we
+ − 138 ; should add the font-lock stuff ourselves during the scanning phase,
+ − 139 ; if font-lock is enabled in this buffer.
+ − 140
+ − 141 ;(defun help-follow-reference (event extent user-data)
+ − 142 ; (let ((symbol (intern-soft (extent-string extent))))
+ − 143 ; (cond ((and symbol (fboundp symbol))
+ − 144 ; (describe-function symbol))
+ − 145 ; ((and symbol (boundp symbol))
+ − 146 ; (describe-variable symbol))
+ − 147 ; (t nil))))
+ − 148
+ − 149 ;(defvar help-font-lock-keywords
+ − 150 ; (let ((name-char "[-+a-zA-Z0-9_*]") (sym-char "[-+a-zA-Z0-9_:*]"))
+ − 151 ; (list
+ − 152 ; ;;
+ − 153 ; ;; The symbol itself.
+ − 154 ; (list (concat "\\`\\(" name-char "+\\)\\(:\\)?")
+ − 155 ; '(1 (if (match-beginning 2)
+ − 156 ; 'font-lock-function-name-face
+ − 157 ; 'font-lock-variable-name-face)
+ − 158 ; nil t))
+ − 159 ; ;;
+ − 160 ; ;; Words inside `' which tend to be symbol names.
+ − 161 ; (list (concat "`\\(" sym-char sym-char "+\\)'")
+ − 162 ; 1 '(prog1
+ − 163 ; 'font-lock-reference-face
+ − 164 ; (add-list-mode-item (match-beginning 1)
+ − 165 ; (match-end 1)
+ − 166 ; nil
+ − 167 ; 'help-follow-reference))
+ − 168 ; t)
+ − 169 ; ;;
+ − 170 ; ;; CLisp `:' keywords as references.
+ − 171 ; (list (concat "\\<:" sym-char "+\\>") 0 'font-lock-reference-face t)))
+ − 172 ; "Default expressions to highlight in Help mode.")
+ − 173
+ − 174 ;(put 'help-mode 'font-lock-defaults '(help-font-lock-keywords))
+ − 175
+ − 176 (define-derived-mode help-mode view-major-mode "Help"
+ − 177 "Major mode for viewing help text.
+ − 178 Entry to this mode runs the normal hook `help-mode-hook'.
+ − 179 Commands:
+ − 180 \\{help-mode-map}"
+ − 181 )
+ − 182
+ − 183 (define-key help-mode-map "q" 'help-mode-quit)
+ − 184
+ − 185 (defun help-mode-quit ()
80
+ − 186 "Exits from help mode, possibly restoring the previous window configuration."
0
+ − 187 (interactive)
114
+ − 188 (cond ((frame-property (selected-frame) 'help-window-config)
+ − 189 (set-window-configuration
+ − 190 (frame-property (selected-frame) 'help-window-config))
+ − 191 (set-frame-property (selected-frame) 'help-window-config nil))
0
+ − 192 ((one-window-p)
+ − 193 (bury-buffer))
+ − 194 (t
+ − 195 (delete-window))))
+ − 196
+ − 197 (defun help-quit ()
+ − 198 (interactive)
+ − 199 nil)
+ − 200
+ − 201 ;; This is a grody hack of the same genotype as `advertised-undo'; if the
+ − 202 ;; bindings of Backspace and C-h are the same, we want the menubar to claim
+ − 203 ;; that `info' in invoked with `C-h i', not `BS i'.
+ − 204
+ − 205 (defun deprecated-help-command ()
+ − 206 (interactive)
+ − 207 (if (eq 'help-command (key-binding "\C-h"))
+ − 208 (setq unread-command-event (character-to-event ?\C-h))
+ − 209 (help-for-help)))
+ − 210
+ − 211 ;;(define-key global-map 'backspace 'deprecated-help-command)
+ − 212
+ − 213 ;; TUTORIAL arg is XEmacs addition
+ − 214 (defun help-with-tutorial (&optional tutorial)
+ − 215 "Select the XEmacs learn-by-doing tutorial.
+ − 216 Optional arg TUTORIAL specifies the tutorial file; default is \"TUTORIAL\"."
+ − 217 (interactive)
+ − 218 (if (null tutorial)
+ − 219 (setq tutorial "TUTORIAL"))
+ − 220 (let ((file (expand-file-name (concat "~/" tutorial))))
+ − 221 (delete-other-windows)
+ − 222 (if (get-file-buffer file)
+ − 223 (switch-to-buffer (get-file-buffer file))
+ − 224 (switch-to-buffer (create-file-buffer file))
+ − 225 (setq buffer-file-name file)
+ − 226 (setq default-directory (expand-file-name "~/"))
+ − 227 (setq buffer-auto-save-file-name nil)
+ − 228 (insert-file-contents (expand-file-name tutorial data-directory))
+ − 229 (goto-char (point-min))
+ − 230 (search-forward "\n<<")
+ − 231 (beginning-of-line)
+ − 232 (delete-region (point) (progn (end-of-line) (point)))
+ − 233 (let ((n (- (window-height (selected-window))
+ − 234 (count-lines (point-min) (point))
+ − 235 6)))
+ − 236 (if (< n 12)
+ − 237 (newline n)
+ − 238 ;; Some people get confused by the large gap.
+ − 239 (newline (/ n 2))
+ − 240 (insert "[Middle of page left blank for didactic purposes. "
+ − 241 "Text continues below]")
+ − 242 (newline (- n (/ n 2)))))
+ − 243 (goto-char (point-min))
+ − 244 (set-buffer-modified-p nil))))
+ − 245
+ − 246 ;; used by describe-key and describe-key-briefly
+ − 247
+ − 248 (defun key-or-menu-binding (key &optional menu-flag)
+ − 249 ;; KEY is any value returned by next-command-event
+ − 250 ;; MENU-FLAG is a symbol that should be set to T if KEY is a menu event,
+ − 251 ;; or NIL otherwise
+ − 252 (let (defn)
+ − 253 (and menu-flag (set menu-flag nil))
+ − 254 ;; If the key typed was really a menu selection, grab the form out
+ − 255 ;; of the event object and intuit the function that would be called,
+ − 256 ;; and describe that instead.
+ − 257 (if (and (vectorp key) (= 1 (length key))
+ − 258 (or (misc-user-event-p (aref key 0))
+ − 259 (eq (car-safe (aref key 0)) 'menu-selection)))
+ − 260 (let ((event (aref key 0)))
+ − 261 (setq defn (if (eventp event)
+ − 262 (list (event-function event) (event-object event))
+ − 263 (cdr event)))
+ − 264 (and menu-flag (set menu-flag t))
+ − 265 (if (eq (car defn) 'eval)
+ − 266 (setq defn (car (cdr defn))))
+ − 267 (if (eq (car-safe defn) 'call-interactively)
+ − 268 (setq defn (car (cdr defn))))
+ − 269 (if (and (consp defn) (null (cdr defn)))
+ − 270 (setq defn (car defn))))
+ − 271 ;; else
+ − 272 (setq defn (key-binding key)))
+ − 273 ;; kludge: if a toolbar button was pressed on, try to find the
+ − 274 ;; binding of the toolbar button.
+ − 275 (if (and (eq defn 'press-toolbar-button)
+ − 276 (vectorp key)
+ − 277 (button-press-event-p (aref key (1- (length key)))))
+ − 278 ;; wait for the button release. We're on shaky ground here ...
+ − 279 (let ((event (next-command-event))
+ − 280 button)
+ − 281 (if (and (button-release-event-p event)
+ − 282 (event-over-toolbar-p event)
+ − 283 (eq 'release-and-activate-toolbar-button
+ − 284 (key-binding (vector event)))
+ − 285 (setq button (event-toolbar-button event)))
+ − 286 (toolbar-button-callback button)
+ − 287 ;; if anything went wrong, try returning the binding of
+ − 288 ;; the button-up event, of the original binding
+ − 289 (or (key-or-menu-binding (vector event))
+ − 290 defn)))
+ − 291 ;; no toolbar kludge
+ − 292 defn)
+ − 293 ))
+ − 294
+ − 295 (defun describe-key-briefly (key)
+ − 296 "Print the name of the function KEY invokes. KEY is a string."
+ − 297 (interactive "kDescribe key briefly: ")
+ − 298 (let (defn menup)
+ − 299 (setq defn (key-or-menu-binding key 'menup))
+ − 300 (if (or (null defn) (integerp defn))
+ − 301 (message "%s is undefined" (key-description key))
+ − 302 ;; If it's a keyboard macro which trivially invokes another command,
+ − 303 ;; document that instead.
+ − 304 (if (or (stringp defn) (vectorp defn))
+ − 305 (setq defn (or (key-binding defn)
+ − 306 defn)))
+ − 307 (let ((last-event (and (vectorp key)
+ − 308 (aref key (1- (length key))))))
+ − 309 (message (if (or (button-press-event-p last-event)
+ − 310 (button-release-event-p last-event))
+ − 311 (gettext "%s at that spot runs the command %s")
+ − 312 (gettext "%s runs the command %s"))
+ − 313 ;; This used to say 'This menu item' but it could also
+ − 314 ;; be a scrollbar event. We can't distinguish at the
+ − 315 ;; moment.
+ − 316 (if menup "This item" (key-description key))
+ − 317 (if (symbolp defn) defn (prin1-to-string defn)))))))
+ − 318
+ − 319 ;; #### this is a horrible piece of shit function that should
+ − 320 ;; not exist. In FSF 19.30 this function has gotten three times
+ − 321 ;; as long and has tons and tons of dumb shit checking
+ − 322 ;; special-display-buffer-names and such crap. I absolutely
+ − 323 ;; refuse to insert that Ebolification here. I wanted to delete
+ − 324 ;; this function entirely but Mly bitched.
+ − 325 ;;
+ − 326 ;; If your user-land code calls this function, rewrite it to
+ − 327 ;; call with-displaying-help-buffer.
+ − 328
+ − 329 (defun print-help-return-message (&optional function)
+ − 330 "Display or return message saying how to restore windows after help command.
+ − 331 Computes a message and applies the optional argument FUNCTION to it.
+ − 332 If FUNCTION is nil, applies `message' to it, thus printing it."
+ − 333 (and (not (get-buffer-window standard-output))
+ − 334 (funcall
+ − 335 (or function 'message)
+ − 336 (concat
+ − 337 (substitute-command-keys
+ − 338 (if (one-window-p t)
+ − 339 (if pop-up-windows
+ − 340 (gettext "Type \\[delete-other-windows] to remove help window.")
+ − 341 (gettext "Type \\[switch-to-buffer] RET to remove help window."))
+ − 342 (gettext "Type \\[switch-to-buffer-other-window] RET to restore the other window.")))
+ − 343 (substitute-command-keys
+ − 344 (gettext " \\[scroll-other-window] to scroll the help."))))))
+ − 345
120
+ − 346 (defcustom help-selects-help-window t
0
+ − 347 "*If nil, use the \"old Emacs\" behavior for Help buffers.
+ − 348 This just displays the buffer in another window, rather than selecting
120
+ − 349 the window."
+ − 350 :type 'boolean
+ − 351 :group 'help-appearance)
0
+ − 352
+ − 353 ;; Use this function for displaying help when C-h something is pressed
+ − 354 ;; or in similar situations. Do *not* use it when you are displaying
+ − 355 ;; a help message and then prompting for input in the minibuffer --
+ − 356 ;; this macro usually selects the help buffer, which is not what you
+ − 357 ;; want in those situations.
2
+ − 358
+ − 359 ;;; ### Should really be a macro (as suggested above) to eliminate the
+ − 360 ;;; requirement of caller to code a lambda form in THUNK -- mrb
0
+ − 361 (defun with-displaying-help-buffer (thunk)
+ − 362 (let ((winconfig (current-window-configuration))
114
+ − 363 (was-one-window (one-window-p))
+ − 364 (help-not-visible
+ − 365 (not (and (windows-of-buffer "*Help*") ;shortcut
+ − 366 (member (selected-frame)
+ − 367 (mapcar 'window-frame
+ − 368 (windows-of-buffer "*Help*")))))))
0
+ − 369 (prog1 (with-output-to-temp-buffer "*Help*"
+ − 370 (prog1 (funcall thunk)
+ − 371 (save-excursion
+ − 372 (set-buffer standard-output)
+ − 373 (help-mode))))
+ − 374 (let ((helpwin (get-buffer-window "*Help*")))
+ − 375 (if helpwin
+ − 376 (progn
+ − 377 (save-excursion
+ − 378 (set-buffer (window-buffer helpwin))
114
+ − 379 ;;If the *Help* buffer is already displayed on this
+ − 380 ;; frame, don't override the previous configuration
+ − 381 (if help-not-visible
+ − 382 (set-frame-property (selected-frame)
+ − 383 'help-window-config winconfig)))
0
+ − 384 (if help-selects-help-window
+ − 385 (select-window helpwin))
+ − 386 (cond ((eq helpwin (selected-window))
+ − 387 (message
+ − 388 (substitute-command-keys "Type \\[help-mode-quit] to remove help window, \\[scroll-up] to scroll the help.")))
+ − 389 (was-one-window
+ − 390 (message
+ − 391 (substitute-command-keys "Type \\[delete-other-windows] to remove help window, \\[scroll-other-window] to scroll the help.")))
+ − 392 (t
+ − 393 (message
116
+ − 394 (substitute-command-keys "Type \\[switch-to-buffer-other-window] to restore the other window, \\[scroll-other-window] to scroll the help."))))))))))
0
+ − 395
+ − 396 (defun describe-key (key)
+ − 397 "Display documentation of the function invoked by KEY.
+ − 398 KEY is a string, or vector of events.
108
+ − 399 When called interactively, KEY may also be a menu selection."
0
+ − 400 (interactive "kDescribe key: ")
+ − 401 (let ((defn (key-or-menu-binding key)))
+ − 402 (if (or (null defn) (integerp defn))
+ − 403 (message "%s is undefined" (key-description key))
+ − 404 (with-displaying-help-buffer
+ − 405 (lambda ()
+ − 406 ; (princ (key-description key))
+ − 407 ; (princ " runs the command ")
+ − 408 (prin1 defn)
+ − 409 (princ ":\n")
+ − 410 (cond ((or (stringp defn) (vectorp defn))
+ − 411 (let ((cmd (key-binding defn)))
+ − 412 (if (not cmd)
+ − 413 (princ "a keyboard macro")
+ − 414 (progn
+ − 415 (princ (format "a keyboard macro which runs the command %s:\n\n"
+ − 416 cmd))
+ − 417 (princ cmd)
+ − 418 (princ "\n")
+ − 419 (if (documentation cmd) (princ (documentation cmd)))))))
+ − 420 ((and (consp defn) (not (eq 'lambda (car-safe defn))))
+ − 421 (princ "\n")
+ − 422 (let ((describe-function-show-arglist nil))
+ − 423 (describe-function-1 (car defn) standard-output)))
+ − 424 ((documentation defn)
+ − 425 (princ (documentation defn)))
+ − 426 (t
+ − 427 (princ "not documented"))))))))
+ − 428
+ − 429 (defun describe-mode ()
+ − 430 "Display documentation of current major mode and minor modes.
+ − 431 For this to work correctly for a minor mode, the mode's indicator variable
+ − 432 \(listed in `minor-mode-alist') must also be a function whose documentation
+ − 433 describes the minor mode."
+ − 434 (interactive)
+ − 435 (with-displaying-help-buffer
+ − 436 (lambda ()
+ − 437 ;; XEmacs change: print the major-mode documentation before
+ − 438 ;; the minor modes.
+ − 439 (princ mode-name)
+ − 440 (princ " mode:\n")
+ − 441 (princ (documentation major-mode))
+ − 442 (princ "\n\n----\n\n")
+ − 443 (let ((minor-modes minor-mode-alist))
+ − 444 (while minor-modes
+ − 445 (let* ((minor-mode (car (car minor-modes)))
+ − 446 (indicator (car (cdr (car minor-modes)))))
+ − 447 ;; Document a minor mode if it is listed in minor-mode-alist,
+ − 448 ;; bound locally in this buffer, non-nil, and has a function
+ − 449 ;; definition.
+ − 450 (if (and (boundp minor-mode)
+ − 451 (symbol-value minor-mode)
+ − 452 (fboundp minor-mode))
+ − 453 (let ((pretty-minor-mode minor-mode))
+ − 454 (if (string-match "-mode\\'" (symbol-name minor-mode))
+ − 455 (setq pretty-minor-mode
+ − 456 (capitalize
+ − 457 (substring (symbol-name minor-mode)
+ − 458 0 (match-beginning 0)))))
+ − 459 (while (and (consp indicator) (extentp (car indicator)))
+ − 460 (setq indicator (cdr indicator)))
+ − 461 (while (and indicator (symbolp indicator))
+ − 462 (setq indicator (symbol-value indicator)))
+ − 463 (princ (format "%s minor mode (indicator%s):\n"
+ − 464 pretty-minor-mode indicator))
+ − 465 (princ (documentation minor-mode))
+ − 466 (princ "\n\n----\n\n"))))
+ − 467 (setq minor-modes (cdr minor-modes)))))))
+ − 468
+ − 469 ;; So keyboard macro definitions are documented correctly
+ − 470 (fset 'defining-kbd-macro (symbol-function 'start-kbd-macro))
+ − 471
+ − 472 (defun describe-distribution ()
+ − 473 "Display info on how to obtain the latest version of XEmacs."
+ − 474 (interactive)
+ − 475 (find-file-read-only
+ − 476 (expand-file-name "DISTRIB" data-directory)))
+ − 477
108
+ − 478 (defun describe-beta ()
+ − 479 "Display info on how to deal with Beta versions of XEmacs."
+ − 480 (interactive)
+ − 481 (find-file-read-only
+ − 482 (expand-file-name "BETA" data-directory))
+ − 483 (goto-char (point-min)))
+ − 484
0
+ − 485 (defun describe-copying ()
+ − 486 "Display info on how you may redistribute copies of XEmacs."
+ − 487 (interactive)
+ − 488 (find-file-read-only
+ − 489 (expand-file-name "COPYING" data-directory))
+ − 490 (goto-char (point-min)))
+ − 491
+ − 492 (defun describe-pointer ()
+ − 493 "Show a list of all defined mouse buttons, and their definitions."
+ − 494 (interactive)
+ − 495 (describe-bindings nil t))
+ − 496
+ − 497 (defun describe-project ()
+ − 498 "Display info on the GNU project."
+ − 499 (interactive)
+ − 500 (find-file-read-only
+ − 501 (expand-file-name "GNU" data-directory))
+ − 502 (goto-char (point-min)))
+ − 503
+ − 504 (defun describe-no-warranty ()
+ − 505 "Display info on all the kinds of warranty XEmacs does NOT have."
+ − 506 (interactive)
+ − 507 (describe-copying)
+ − 508 (let (case-fold-search)
+ − 509 (search-forward "NO WARRANTY")
+ − 510 (recenter 0)))
+ − 511
+ − 512 (defun describe-bindings (&optional prefix mouse-only-p)
+ − 513 "Show a list of all defined keys, and their definitions.
+ − 514 The list is put in a buffer, which is displayed.
+ − 515 If the optional argument PREFIX is supplied, only commands which
+ − 516 start with that sequence of keys are described.
+ − 517 If the second argument (prefix arg, interactively) is non-null
+ − 518 then only the mouse bindings are displayed."
+ − 519 (interactive (list nil current-prefix-arg))
+ − 520 (with-displaying-help-buffer
+ − 521 (lambda ()
+ − 522 (describe-bindings-1 prefix mouse-only-p))))
+ − 523
+ − 524 (defun describe-bindings-1 (&optional prefix mouse-only-p)
+ − 525 (let ((heading (if mouse-only-p
+ − 526 (gettext "button binding\n------ -------\n")
+ − 527 (gettext "key binding\n--- -------\n")))
+ − 528 (buffer (current-buffer))
+ − 529 (minor minor-mode-map-alist)
+ − 530 (local (current-local-map))
+ − 531 (shadow '()))
+ − 532 (set-buffer standard-output)
+ − 533 (while minor
+ − 534 (let ((sym (car (car minor)))
+ − 535 (map (cdr (car minor))))
+ − 536 (if (symbol-value-in-buffer sym buffer nil)
+ − 537 (progn
+ − 538 (insert (format "Minor Mode Bindings for `%s':\n"
+ − 539 sym)
+ − 540 heading)
+ − 541 (describe-bindings-internal map nil shadow prefix mouse-only-p)
+ − 542 (insert "\n")
+ − 543 (setq shadow (cons map shadow))))
+ − 544 (setq minor (cdr minor))))
+ − 545 (if local
+ − 546 (progn
+ − 547 (insert "Local Bindings:\n" heading)
+ − 548 (describe-bindings-internal local nil shadow prefix mouse-only-p)
+ − 549 (insert "\n")
+ − 550 (setq shadow (cons local shadow))))
+ − 551 (insert "Global Bindings:\n" heading)
+ − 552 (describe-bindings-internal (current-global-map)
+ − 553 nil shadow prefix mouse-only-p)
+ − 554 (set-buffer buffer)))
+ − 555
+ − 556 (defun describe-prefix-bindings ()
+ − 557 "Describe the bindings of the prefix used to reach this command.
+ − 558 The prefix described consists of all but the last event
+ − 559 of the key sequence that ran this command."
+ − 560 (interactive)
+ − 561 (let* ((key (this-command-keys))
+ − 562 (prefix (make-vector (1- (length key)) nil))
+ − 563 i)
+ − 564 (setq i 0)
+ − 565 (while (< i (length prefix))
+ − 566 (aset prefix i (aref key i))
+ − 567 (setq i (1+ i)))
+ − 568 (with-displaying-help-buffer
+ − 569 (lambda ()
+ − 570 (princ "Key bindings starting with ")
+ − 571 (princ (key-description prefix))
+ − 572 (princ ":\n\n")
+ − 573 (describe-bindings-1 prefix nil)))))
+ − 574
+ − 575 ;; Make C-h after a prefix, when not specifically bound,
+ − 576 ;; run describe-prefix-bindings.
+ − 577 (setq prefix-help-command 'describe-prefix-bindings)
+ − 578
+ − 579 (defun view-emacs-news ()
+ − 580 "Display info on recent changes to XEmacs."
+ − 581 (interactive)
+ − 582 (require 'outl-mouse)
+ − 583 (find-file (expand-file-name "NEWS" data-directory)))
+ − 584
+ − 585 (defun xemacs-www-page ()
+ − 586 "Go to the XEmacs World Wide Web page."
+ − 587 (interactive)
+ − 588 (funcall browse-url-browser-function "http://www.xemacs.org/"))
+ − 589
+ − 590 (defun xemacs-www-faq ()
+ − 591 "View the latest and greatest XEmacs FAQ using the World Wide Web."
+ − 592 (interactive)
+ − 593 (funcall browse-url-browser-function "http://www.xemacs.org/faq/index.html"))
+ − 594
+ − 595 (defun xemacs-local-faq ()
+ − 596 "View the local copy of the XEmacs FAQ.
+ − 597 If you have access to the World Wide Web, you should use `xemacs-www-faq'
+ − 598 instead, to ensure that you get the most up-to-date information."
+ − 599 (interactive)
+ − 600 (save-window-excursion
+ − 601 (info)
+ − 602 (Info-find-node "xemacs-faq" "Top"))
+ − 603 (switch-to-buffer "*info*"))
+ − 604
+ − 605 (defun view-lossage ()
+ − 606 "Display last 100 input keystrokes and last 100 or so minibuffer messages."
+ − 607 (interactive)
+ − 608 (with-displaying-help-buffer
+ − 609 (lambda ()
+ − 610 (princ (key-description (recent-keys)))
+ − 611 (save-excursion
+ − 612 (set-buffer standard-output)
+ − 613 (goto-char (point-min))
+ − 614 (insert "Recent keystrokes:\n\n")
+ − 615 (while (progn (move-to-column 50) (not (eobp)))
+ − 616 (search-forward " " nil t)
+ − 617 (insert "\n")))
+ − 618 ;; XEmacs addition
+ − 619 (princ "\n\n\nRecent minibuffer messages (most recent first):\n\n")
+ − 620 (save-excursion
+ − 621 (let ((buffer (get-buffer " *Message-Log*"))
+ − 622 (count 0)
+ − 623 oldpoint)
+ − 624 (set-buffer buffer)
+ − 625 (goto-char (point-max))
+ − 626 (set-buffer standard-output)
+ − 627 (while (and (> (point buffer) (point-min buffer))
+ − 628 (< count 100))
+ − 629 (setq oldpoint (point buffer))
+ − 630 (forward-line -1 buffer)
+ − 631 (insert-buffer-substring buffer (point buffer) oldpoint)
+ − 632 (setq count (1+ count))))))))
+ − 633
+ − 634 (define-function 'help 'help-for-help)
+ − 635 ;; #### FSF calls `make-help-screen' here. We need to port `help-macro.el'.
+ − 636 (defun help-for-help ()
+ − 637 "You have typed \\[help-for-help], the help character. Type a Help option:
+ − 638 \(Use SPC or DEL to scroll through this text. Type \\<help-map>\\[help-quit] to exit the Help command.)
+ − 639
+ − 640 \\[hyper-apropos] Give a substring, and see a hypertext list of
+ − 641 functions and variables that contain that substring.
+ − 642 See also the `apropos' command.
+ − 643 \\[command-apropos] Give a substring, and see a list of commands
+ − 644 (functions interactively callable) that contain that substring.
+ − 645 \\[describe-bindings] Display table of all key bindings.
+ − 646 \\[describe-key-briefly] Type a command key sequence;
+ − 647 it prints the function name that sequence runs.
+ − 648 \\[Info-goto-emacs-command-node] Type a function name;
+ − 649 it takes you to the Info node for that command.
+ − 650 \\[describe-function] Type a function name and get documentation of it.
+ − 651 \\[Info-elisp-ref] Type a function name and jump to the full documentation
+ − 652 in the XEmacs Lisp Programmer's Manual.
+ − 653 \\[xemacs-local-faq] To view a local copy of the XEmacs FAQ.
+ − 654 \\[info] The info documentation reader.
+ − 655 \\[Info-query] Info reader, prompt for topic name.
+ − 656 \\[describe-key] Type a command key sequence;
+ − 657 it displays the full documentation.
+ − 658 \\[Info-goto-emacs-key-command-node] Type a command key sequence;
+ − 659 it takes you to the Info node for the command bound to that key.
+ − 660 \\[view-lossage] Shows last 100 characters you typed.
+ − 661 \\[describe-mode] Print documentation of current major mode,
+ − 662 which describes the commands peculiar to it.
+ − 663 \\[view-emacs-news] Shows emacs news file.
+ − 664 \\[finder-by-keyword] Find packages matching a given topic keyword.
+ − 665 \\[describe-pointer] Display table of all mouse-button bindings.
+ − 666 \\[describe-syntax] Display contents of syntax table, plus explanations
+ − 667 \\[help-with-tutorial] Select the XEmacs learn-by-doing tutorial.
+ − 668 \\[describe-variable] Type name of a variable;
+ − 669 it displays the variable's documentation and value.
+ − 670 \\[where-is] Type command name;
+ − 671 it prints which keystrokes invoke that command.
+ − 672 \\[describe-distribution] XEmacs ordering information.
+ − 673 \\[describe-copying] print XEmacs copying permission (General Public License).
+ − 674 \\[view-emacs-news] print print news of recent XEmacs changes.
+ − 675 \\[describe-no-warranty] print information on absence of warranty for XEmacs."
+ − 676 (interactive)
+ − 677 (let ((help-key (copy-event last-command-event))
+ − 678 event char)
+ − 679 (message (gettext "A B C F I K L M N P S T V W C-c C-d C-n C-w. Type %s again for more help: ")
+ − 680 ;; arrgh, no room for "C-i C-k C-f" !!
+ − 681 (single-key-description help-key))
+ − 682 (setq event (next-command-event)
+ − 683 char (event-to-character event))
+ − 684 (if (or (equal event help-key)
+ − 685 (eq char ??)
+ − 686 (eq 'help-command (key-binding event)))
+ − 687 (save-window-excursion
+ − 688 (switch-to-buffer "*Help*")
+ − 689 ;; #### I18N3 should mark buffer as output-translating
+ − 690 (delete-other-windows)
+ − 691 (let ((buffer-read-only nil))
+ − 692 (erase-buffer)
+ − 693 (insert (documentation 'help-for-help)))
+ − 694 (goto-char (point-min))
+ − 695 (while (or (equal event help-key)
+ − 696 (eq char ??)
+ − 697 (eq 'help-command (key-binding event))
+ − 698 (eq char ? )
+ − 699 (eq 'scroll-up (key-binding event))
+ − 700 (eq char ?\177)
76
+ − 701 (and (not (eq char ?b))
+ − 702 (eq 'scroll-down (key-binding event))))
0
+ − 703 (if (or (eq char ? )
+ − 704 (eq 'scroll-up (key-binding event)))
+ − 705 (scroll-up))
+ − 706 (if (or (eq char ?\177)
76
+ − 707 (and (not (eq char ?b))
+ − 708 (eq 'scroll-down (key-binding event))))
0
+ − 709 (scroll-down))
+ − 710 ;; write this way for I18N3 snarfing
+ − 711 (if (pos-visible-in-window-p (point-max))
+ − 712 (message "A B C F I K L M N P S T V W C-c C-d C-n C-w C-i C-k C-f: ")
+ − 713 (message "A B C F I K L M N P S T V W C-c C-d C-n C-w C-i C-k C-f or Space to scroll: "))
+ − 714 (let ((cursor-in-echo-area t))
+ − 715 (setq event (next-command-event event)
+ − 716 char (or (event-to-character event) event))))))
+ − 717 (let ((defn (or (lookup-key help-map (vector event))
+ − 718 (and (numberp char)
+ − 719 (lookup-key help-map (make-string 1 (downcase char)))))))
+ − 720 (message nil)
+ − 721 (if defn
+ − 722 (call-interactively defn)
+ − 723 (ding)))))
+ − 724
+ − 725 ;; Return a function which is called by the list containing point.
+ − 726 ;; If that gives no function, return a function whose name is around point.
+ − 727 ;; If that doesn't give a function, return nil.
+ − 728 (defun function-called-at-point ()
+ − 729 (or (condition-case ()
+ − 730 (save-excursion
+ − 731 (save-restriction
+ − 732 (narrow-to-region (max (point-min) (- (point) 1000)) (point-max))
+ − 733 (backward-up-list 1)
+ − 734 (forward-char 1)
+ − 735 (let (obj)
+ − 736 (setq obj (read (current-buffer)))
+ − 737 (and (symbolp obj) (fboundp obj) obj))))
+ − 738 (error nil))
+ − 739 (condition-case ()
+ − 740 (let ((stab (syntax-table)))
+ − 741 (unwind-protect
+ − 742 (save-excursion
+ − 743 (set-syntax-table emacs-lisp-mode-syntax-table)
+ − 744 (or (not (zerop (skip-syntax-backward "_w")))
+ − 745 (eq (char-syntax (following-char)) ?w)
+ − 746 (eq (char-syntax (following-char)) ?_)
+ − 747 (forward-sexp -1))
+ − 748 (skip-chars-forward "`'")
+ − 749 (let ((obj (read (current-buffer))))
+ − 750 (and (symbolp obj) (fboundp obj) obj)))
+ − 751 (set-syntax-table stab)))
+ − 752 (error nil))))
+ − 753
120
+ − 754 ;; default to nil for the non-hackers?
+ − 755 (defcustom describe-function-show-arglist t
+ − 756 "*If non-nil, describe-function will show its arglist,
+ − 757 unless the function is autoloaded."
+ − 758 :type 'boolean
+ − 759 :group 'help-appearance)
0
+ − 760
+ − 761 (defun describe-function-find-file (function)
+ − 762 (and (boundp 'load-history) ; not standardly bound in XEmacs
+ − 763 (let ((files load-history)
+ − 764 file)
+ − 765 (while files
+ − 766 (if (memq function (cdr (car files)))
+ − 767 (setq file (car (car files)) files nil))
+ − 768 (setq files (cdr files)))
+ − 769 file)))
+ − 770
+ − 771 (defun describe-function (function)
+ − 772 "Display the full documentation of FUNCTION (a symbol)."
+ − 773 (interactive
+ − 774 (let* ((fn (function-called-at-point))
+ − 775 (val (let ((enable-recursive-minibuffers t))
+ − 776 (completing-read
+ − 777 (if fn
+ − 778 (format (gettext "Describe function (default %s): ")
+ − 779 fn)
+ − 780 (gettext "Describe function: "))
+ − 781 obarray 'fboundp t))))
+ − 782 (list (if (equal val "") fn (intern val)))))
+ − 783 (with-displaying-help-buffer
+ − 784 (lambda ()
+ − 785 (describe-function-1 function standard-output)
+ − 786 (save-excursion
+ − 787 (set-buffer standard-output)
+ − 788 ;; Return the text we displayed.
+ − 789 (buffer-string)))))
+ − 790
+ − 791 (defun function-obsolete-p (function)
+ − 792 "Return non-nil if FUNCTION is obsolete."
+ − 793 (not (null (get function 'byte-obsolete-info))))
+ − 794
+ − 795 (defun function-obsoleteness-doc (function)
+ − 796 "If FUNCTION is obsolete, return a string describing this."
+ − 797 (let ((obsolete (get function 'byte-obsolete-info)))
+ − 798 (if obsolete
+ − 799 (format "Obsolete; %s"
+ − 800 (if (stringp (car obsolete))
+ − 801 (car obsolete)
+ − 802 (format "use `%s' instead." (car obsolete)))))))
+ − 803
100
+ − 804 (defun function-compatible-p (function)
+ − 805 "Return non-nil if FUNCTION is present for Emacs compatibility."
+ − 806 (not (null (get function 'byte-compatible-info))))
+ − 807
+ − 808 (defun function-compatibility-doc (function)
+ − 809 "If FUNCTION is Emacs compatible, return a string describing this."
+ − 810 (let ((compatible (get function 'byte-compatible-info)))
+ − 811 (if compatible
+ − 812 (format "Emacs Compatible; %s"
+ − 813 (if (stringp (car compatible))
+ − 814 (car compatible)
+ − 815 (format "use `%s' instead." (car compatible)))))))
+ − 816
0
+ − 817 ;Here are all the possibilities below spelled out, for the benefit
+ − 818 ;of the I18N3 snarfer.
+ − 819 ;
+ − 820 ;(gettext "a built-in function")
+ − 821 ;(gettext "an interactive built-in function")
+ − 822 ;(gettext "a built-in macro")
+ − 823 ;(gettext "an interactive built-in macro")
+ − 824 ;(gettext "a compiled Lisp function")
+ − 825 ;(gettext "an interactive compiled Lisp function")
+ − 826 ;(gettext "a compiled Lisp macro")
+ − 827 ;(gettext "an interactive compiled Lisp macro")
+ − 828 ;(gettext "a Lisp function")
+ − 829 ;(gettext "an interactive Lisp function")
+ − 830 ;(gettext "a Lisp macro")
+ − 831 ;(gettext "an interactive Lisp macro")
+ − 832 ;(gettext "a mocklisp function")
+ − 833 ;(gettext "an interactive mocklisp function")
+ − 834 ;(gettext "a mocklisp macro")
+ − 835 ;(gettext "an interactive mocklisp macro")
+ − 836 ;(gettext "an autoloaded Lisp function")
+ − 837 ;(gettext "an interactive autoloaded Lisp function")
+ − 838 ;(gettext "an autoloaded Lisp macro")
+ − 839 ;(gettext "an interactive autoloaded Lisp macro")
+ − 840
+ − 841 (defun describe-function-1 (function stream &optional nodoc)
+ − 842 (prin1 function stream)
+ − 843 (princ ": " stream)
+ − 844 (let* ((def function)
+ − 845 file-name
+ − 846 (doc (or (documentation function)
+ − 847 (gettext "not documented")))
104
+ − 848 aliases home kbd-macro-p fndef macrop)
0
+ − 849 (while (symbolp def)
+ − 850 (or (eq def function)
+ − 851 (if aliases
+ − 852 ;; I18N3 Need gettext due to concat
+ − 853 (setq aliases (concat aliases
+ − 854 (format "\n which is an alias for %s, "
+ − 855 (symbol-name def))))
+ − 856 (setq aliases (format "an alias for %s, " (symbol-name def)))))
+ − 857 (setq def (symbol-function def)))
104
+ − 858 (if (compiled-function-p def)
+ − 859 (setq home (compiled-function-annotation def)))
0
+ − 860 (if (eq 'macro (car-safe def))
+ − 861 (setq fndef (cdr def)
+ − 862 macrop t)
+ − 863 (setq fndef def))
+ − 864 (if describe-function-show-arglist
+ − 865 (if (cond ((eq 'autoload (car-safe fndef))
+ − 866 nil)
+ − 867 ((eq 'lambda (car-safe fndef))
+ − 868 (princ (or (nth 1 fndef) "()") stream)
+ − 869 t)
+ − 870 ((compiled-function-p fndef)
+ − 871 (princ (or (compiled-function-arglist fndef) "()") stream)
+ − 872 t)
+ − 873 ((and (subrp fndef)
+ − 874 (string-match "[\n\t ]*\narguments: ?\\((.*)\\)\n?\\'"
+ − 875 doc))
+ − 876 (princ (substring doc (match-beginning 1) (match-end 1))
+ − 877 stream)
+ − 878 (setq doc (substring doc 0 (match-beginning 0)))
+ − 879 t)
+ − 880 (t
+ − 881 nil))
+ − 882 (princ "\n -- " stream)))
+ − 883 (if aliases (princ aliases stream))
+ − 884 (let ((int #'(lambda (string an-p macro-p)
+ − 885 (princ (format
+ − 886 (gettext (concat
+ − 887 (cond ((commandp def)
+ − 888 "an interactive ")
+ − 889 (an-p "an ")
+ − 890 (t "a "))
+ − 891 "%s"
+ − 892 (if macro-p " macro" " function")))
+ − 893 string)
+ − 894 stream))))
+ − 895 (cond ((or (stringp def) (vectorp def))
+ − 896 (princ "a keyboard macro." stream)
+ − 897 (setq kbd-macro-p t))
+ − 898 ((subrp fndef)
+ − 899 (funcall int "built-in" nil macrop))
+ − 900 ((compiled-function-p fndef)
+ − 901 (funcall int "compiled Lisp" nil macrop))
+ − 902 ; XEmacs -- we handle aliases above.
+ − 903 ; ((symbolp fndef)
+ − 904 ; (princ (format "alias for `%s'"
+ − 905 ; (prin1-to-string def)) stream))
+ − 906 ((eq (car-safe fndef) 'lambda)
+ − 907 (funcall int "Lisp" nil macrop))
+ − 908 ((eq (car-safe fndef) 'mocklisp)
+ − 909 (funcall int "mocklisp" nil macrop))
+ − 910 ((eq (car-safe def) 'autoload)
+ − 911 (setq file-name (elt def 1))
+ − 912 (funcall int "autoloaded Lisp" t (elt def 4)))
+ − 913 (t
+ − 914 nil)))
+ − 915 (or file-name
+ − 916 (setq file-name (describe-function-find-file function)))
+ − 917 (if file-name
+ − 918 (princ (format ".\n -- loads from \"%s\"" file-name) stream))
104
+ − 919 (if home
+ − 920 (princ (format ".\n -- loaded from %s" home)))
110
+ − 921 (princ "." stream)
+ − 922 (terpri stream)
0
+ − 923 (cond (kbd-macro-p
+ − 924 (princ "These characters are executed:\n\n\t" stream)
+ − 925 (princ (key-description def) stream)
+ − 926 (cond ((setq def (key-binding def))
+ − 927 (princ (format "\n\nwhich executes the command %s.\n\n" def) stream)
+ − 928 (describe-function-1 def stream))))
+ − 929 (nodoc nil)
+ − 930 (t
+ − 931 ;; tell the user about obsoleteness.
+ − 932 ;; If the function is obsolete and is aliased, don't
+ − 933 ;; even bother to report the documentation, as a further
+ − 934 ;; encouragement to use the new function.
100
+ − 935 (let ((obsolete (function-obsoleteness-doc function))
+ − 936 (compatible (function-compatibility-doc function)))
0
+ − 937 (if obsolete
+ − 938 (progn
+ − 939 (princ obsolete stream)
+ − 940 (terpri stream)
+ − 941 (terpri stream)))
100
+ − 942 (if compatible
+ − 943 (progn
+ − 944 (princ compatible stream)
+ − 945 (terpri stream)
+ − 946 (terpri stream)))
0
+ − 947 (if (not (and obsolete aliases))
+ − 948 (progn
+ − 949 (princ doc stream)
118
+ − 950 (or (equal doc "")
+ − 951 (eq ?\n (aref doc (1- (length doc))))
110
+ − 952 (terpri stream)))))))))
0
+ − 953
+ − 954
+ − 955 (defun describe-function-arglist (function)
+ − 956 (interactive (list (or (function-called-at-point)
+ − 957 (error "no function call at point"))))
+ − 958 (let ((b nil))
+ − 959 (unwind-protect
+ − 960 (save-excursion
+ − 961 (set-buffer (setq b (get-buffer-create " *arglist*")))
+ − 962 (buffer-disable-undo b)
+ − 963 (erase-buffer)
+ − 964 (describe-function-1 function b t)
+ − 965 (goto-char (point-min))
+ − 966 (end-of-line)
+ − 967 (or (eobp) (delete-char 1))
+ − 968 (just-one-space)
+ − 969 (end-of-line)
+ − 970 (message (buffer-substring (point-min) (point))))
+ − 971 (and b (kill-buffer b)))))
+ − 972
+ − 973
+ − 974 (defun variable-at-point ()
+ − 975 (condition-case ()
+ − 976 (let ((stab (syntax-table)))
+ − 977 (unwind-protect
+ − 978 (save-excursion
+ − 979 (set-syntax-table emacs-lisp-mode-syntax-table)
+ − 980 (or (not (zerop (skip-syntax-backward "_w")))
+ − 981 (eq (char-syntax (following-char)) ?w)
+ − 982 (eq (char-syntax (following-char)) ?_)
+ − 983 (forward-sexp -1))
+ − 984 (skip-chars-forward "'")
+ − 985 (let ((obj (read (current-buffer))))
+ − 986 (and (symbolp obj) (boundp obj) obj)))
+ − 987 (set-syntax-table stab)))
+ − 988 (error nil)))
+ − 989
+ − 990 (defun variable-obsolete-p (variable)
+ − 991 "Return non-nil if VARIABLE is obsolete."
+ − 992 (not (null (get variable 'byte-obsolete-variable))))
+ − 993
+ − 994 (defun variable-obsoleteness-doc (variable)
+ − 995 "If VARIABLE is obsolete, return a string describing this."
+ − 996 (let ((obsolete (get variable 'byte-obsolete-variable)))
+ − 997 (if obsolete
+ − 998 (format "Obsolete; %s"
+ − 999 (if (stringp obsolete)
+ − 1000 obsolete
+ − 1001 (format "use `%s' instead." obsolete))))))
+ − 1002
100
+ − 1003 (defun variable-compatible-p (variable)
+ − 1004 "Return non-nil if VARIABLE is Emacs compatible."
+ − 1005 (not (null (get variable 'byte-compatible-variable))))
+ − 1006
+ − 1007 (defun variable-compatibility-doc (variable)
+ − 1008 "If VARIABLE is Emacs compatible, return a string describing this."
+ − 1009 (let ((compatible (get variable 'byte-compatible-variable)))
+ − 1010 (if compatible
+ − 1011 (format "Emacs Compatible; %s"
+ − 1012 (if (stringp compatible)
+ − 1013 compatible
+ − 1014 (format "use `%s' instead." compatible))))))
+ − 1015
0
+ − 1016 (defun built-in-variable-doc (variable)
+ − 1017 "Return a string describing whether VARIABLE is built-in."
+ − 1018 (let ((type (built-in-variable-type variable)))
+ − 1019 (cond ((eq type 'integer) "a built-in integer variable")
+ − 1020 ((eq type 'const-integer) "a built-in constant integer variable")
+ − 1021 ((eq type 'boolean) "a built-in boolean variable")
+ − 1022 ((eq type 'const-boolean) "a built-in constant boolean variable")
+ − 1023 ((eq type 'object) "a simple built-in variable")
+ − 1024 ((eq type 'const-object) "a simple built-in constant variable")
+ − 1025 ((eq type 'const-specifier) "a built-in constant specifier variable")
+ − 1026 ((eq type 'current-buffer) "a built-in buffer-local variable")
+ − 1027 ((eq type 'const-current-buffer)
+ − 1028 "a built-in constant buffer-local variable")
+ − 1029 ((eq type 'default-buffer)
+ − 1030 "a built-in default buffer-local variable")
+ − 1031 ((eq type 'selected-console) "a built-in console-local variable")
+ − 1032 ((eq type 'const-selected-console)
+ − 1033 "a built-in constant console-local variable")
+ − 1034 ((eq type 'default-console)
+ − 1035 "a built-in default console-local variable")
+ − 1036 (type "an unknown type of built-in variable?")
+ − 1037 (t "a variable declared in Lisp"))))
+ − 1038
+ − 1039 (defun describe-variable (variable)
+ − 1040 "Display the full documentation of VARIABLE (a symbol)."
+ − 1041 (interactive
+ − 1042 (let* ((v (variable-at-point))
+ − 1043 (val (let ((enable-recursive-minibuffers t))
+ − 1044 (completing-read
+ − 1045 (if v
+ − 1046 (format "Describe variable (default %s): " v)
+ − 1047 (gettext "Describe variable: "))
+ − 1048 obarray 'boundp t))))
+ − 1049 (list (if (equal val "") v (intern val)))))
+ − 1050 (with-displaying-help-buffer
+ − 1051 (lambda ()
+ − 1052 (let ((origvar variable)
+ − 1053 aliases)
+ − 1054 (let ((print-escape-newlines t))
+ − 1055 (while (variable-alias variable)
+ − 1056 (let ((newvar (variable-alias variable)))
+ − 1057 (if aliases
+ − 1058 ;; I18N3 Need gettext due to concat
+ − 1059 (setq aliases
+ − 1060 (concat aliases
+ − 1061 (format ",\n which is an alias for %s"
+ − 1062 (symbol-name newvar))))
+ − 1063 (setq aliases
+ − 1064 (format "%s is an alias for %s"
+ − 1065 (symbol-name variable)
+ − 1066 (symbol-name newvar))))
+ − 1067 (setq variable newvar)))
+ − 1068 (if aliases
+ − 1069 (princ (format "%s.\n" aliases)))
+ − 1070 (if (not (boundp variable))
+ − 1071 (princ (format "%s is void" variable))
+ − 1072 (princ (format "%s's value is " variable))
+ − 1073 (prin1 (symbol-value variable)))
+ − 1074 (terpri)
+ − 1075 (princ " -- ")
+ − 1076 (princ (built-in-variable-doc variable))
+ − 1077 (princ ".")
+ − 1078 (terpri)
+ − 1079 (cond ((local-variable-p variable (current-buffer))
+ − 1080 (let* ((void (cons nil nil))
+ − 1081 (def (condition-case nil
+ − 1082 (default-value variable)
+ − 1083 (error void))))
+ − 1084 (princ "This value is specific to the current buffer.")
+ − 1085 (terpri)
+ − 1086 (if (local-variable-p variable nil)
+ − 1087 (progn
+ − 1088 (princ "(Its value is local to each buffer.)")
+ − 1089 (terpri)))
+ − 1090 (if (if (eq def void)
+ − 1091 (boundp variable)
+ − 1092 (not (eq (symbol-value variable) def)))
+ − 1093 ;; #### I18N3 doesn't localize properly!
+ − 1094 (progn (princ "Its default-value is ")
+ − 1095 (if (eq def void)
+ − 1096 (princ "void.")
+ − 1097 (prin1 def))
+ − 1098 (terpri)))))
+ − 1099 ((local-variable-p variable (current-buffer) t)
+ − 1100 (princ "Setting it would make its value buffer-local.\n")
+ − 1101 (terpri))))
+ − 1102 (terpri)
+ − 1103 (princ "Documentation:")
+ − 1104 (terpri)
+ − 1105 (let ((doc (documentation-property variable 'variable-documentation))
100
+ − 1106 (obsolete (variable-obsoleteness-doc origvar))
+ − 1107 (compatible (variable-compatibility-doc origvar)))
0
+ − 1108 (if obsolete
+ − 1109 (progn
+ − 1110 (princ obsolete)
+ − 1111 (terpri)
+ − 1112 (terpri)))
100
+ − 1113 (if compatible
+ − 1114 (progn
+ − 1115 (princ compatible)
+ − 1116 (terpri)
+ − 1117 (terpri)))
0
+ − 1118 ;; don't bother to print anything if variable is obsolete and aliased.
120
+ − 1119 (when (or (not obsolete) (not aliases))
+ − 1120 (if doc
+ − 1121 ;; note: documentation-property calls substitute-command-keys.
+ − 1122 (princ doc)
+ − 1123 (princ "not documented as a variable."))
+ − 1124 (terpri)))
0
+ − 1125 (save-excursion
+ − 1126 (set-buffer standard-output)
+ − 1127 ;; Return the text we displayed.
+ − 1128 (buffer-string))))))
+ − 1129
+ − 1130 (defun where-is (definition)
+ − 1131 "Print message listing key sequences that invoke specified command.
+ − 1132 Argument is a command definition, usually a symbol with a function definition."
+ − 1133 (interactive
+ − 1134 (let ((fn (function-called-at-point))
+ − 1135 (enable-recursive-minibuffers t)
+ − 1136 val)
+ − 1137 ;; #### should use `read-command'
+ − 1138 (setq val (completing-read (if fn
+ − 1139 (format "Where is command (default %s): " fn)
+ − 1140 "Where is command: ")
+ − 1141 obarray 'commandp t nil
+ − 1142 'read-command-history))
+ − 1143 (list (if (equal val "")
+ − 1144 fn (intern val)))))
+ − 1145 (let ((keys (where-is-internal definition)))
+ − 1146 (if keys
+ − 1147 (message "%s is on %s" definition
+ − 1148 (mapconcat 'key-description
+ − 1149 (sort keys #'(lambda (x y)
+ − 1150 (< (length x) (length y))))
+ − 1151 ", "))
+ − 1152 (message "%s is not on any keys" definition)))
+ − 1153 nil)
+ − 1154
110
+ − 1155 ;; Synched with Emacs 19.35
+ − 1156 (defun locate-library (library &optional nosuffix path interactive-call)
+ − 1157 "Show the precise file name of Emacs library LIBRARY.
0
+ − 1158 This command searches the directories in `load-path' like `M-x load-library'
+ − 1159 to find the file that `M-x load-library RET LIBRARY RET' would load.
+ − 1160 Optional second arg NOSUFFIX non-nil means don't add suffixes `.elc' or `.el'
110
+ − 1161 to the specified name LIBRARY.
+ − 1162
+ − 1163 If the optional third arg PATH is specified, that list of directories
+ − 1164 is used instead of `load-path'."
+ − 1165 (interactive (list (read-string "Locate library: ")
+ − 1166 nil nil
+ − 1167 t))
+ − 1168 (let (result)
+ − 1169 (catch 'answer
+ − 1170 (mapcar
+ − 1171 (lambda (dir)
+ − 1172 (mapcar
+ − 1173 (lambda (suf)
+ − 1174 (let ((try (expand-file-name (concat library suf) dir)))
+ − 1175 (and (file-readable-p try)
+ − 1176 (null (file-directory-p try))
+ − 1177 (progn
+ − 1178 (setq result try)
+ − 1179 (throw 'answer try)))))
+ − 1180 (if nosuffix
+ − 1181 '("")
+ − 1182 (let ((basic '(".elc" ".el" ""))
+ − 1183 (compressed '(".Z" ".gz" "")))
+ − 1184 ;; If autocompression mode is on,
+ − 1185 ;; consider all combinations of library suffixes
+ − 1186 ;; and compression suffixes.
+ − 1187 (if (rassq 'jka-compr-handler file-name-handler-alist)
+ − 1188 (apply 'nconc
+ − 1189 (mapcar (lambda (compelt)
+ − 1190 (mapcar (lambda (baselt)
+ − 1191 (concat baselt compelt))
+ − 1192 basic))
+ − 1193 compressed))
+ − 1194 basic)))))
+ − 1195 (or path load-path)))
+ − 1196 (and interactive-call
+ − 1197 (if result
+ − 1198 (message "Library is file %s" result)
+ − 1199 (message "No library %s in search path" library)))
+ − 1200 result))
0
+ − 1201
+ − 1202 ;; Functions ported from C into Lisp in XEmacs
+ − 1203
+ − 1204 (defun describe-syntax ()
+ − 1205 "Describe the syntax specifications in the syntax table.
+ − 1206 The descriptions are inserted in a buffer, which is then displayed."
+ − 1207 (interactive)
+ − 1208 (with-displaying-help-buffer
+ − 1209 (lambda ()
+ − 1210 ;; defined in syntax.el
+ − 1211 (describe-syntax-table (syntax-table) standard-output))))
+ − 1212
+ − 1213 (defun list-processes ()
+ − 1214 "Display a list of all processes.
+ − 1215 \(Any processes listed as Exited or Signaled are actually eliminated
+ − 1216 after the listing is made.)"
+ − 1217 (interactive)
+ − 1218 (with-output-to-temp-buffer "*Process List*"
+ − 1219 (set-buffer standard-output)
+ − 1220 (buffer-disable-undo standard-output)
+ − 1221 (make-local-variable 'truncate-lines)
+ − 1222 (setq truncate-lines t)
+ − 1223 (let ((stream standard-output))
+ − 1224 ;; 00000000001111111111222222222233333333334444444444
+ − 1225 ;; 01234567890123456789012345678901234567890123456789
+ − 1226 ;; rewritten for I18N3. This one should stay rewritten
+ − 1227 ;; so that the dashes will line up properly.
+ − 1228 (princ "Proc Status Buffer Tty Command\n---- ------ ------ --- -------\n" stream)
+ − 1229 (let ((tail (process-list)))
+ − 1230 (while tail
+ − 1231 (let* ((p (car tail))
+ − 1232 (pid (process-id p))
+ − 1233 (s (process-status p)))
+ − 1234 (setq tail (cdr tail))
+ − 1235 (princ (format "%-13s" (process-name p)) stream)
+ − 1236 ;(if (and (eq system-type 'vax-vms)
+ − 1237 ; (eq s 'signal)
+ − 1238 ; (< (process-exit-status p) NSIG))
+ − 1239 ; (princ (aref sys_errlist (process-exit-status p)) stream))
+ − 1240 (princ s stream)
+ − 1241 (if (and (eq s 'exit) (/= (process-exit-status p) 0))
+ − 1242 (princ (format " %d" (process-exit-status p)) stream))
+ − 1243 (if (memq s '(signal exit closed))
+ − 1244 ;; Do delete-exited-processes' work
+ − 1245 (delete-process p))
+ − 1246 (indent-to 22 1) ;####
+ − 1247 (let ((b (process-buffer p)))
+ − 1248 (cond ((not b)
+ − 1249 (princ "(none)" stream))
+ − 1250 ((not (buffer-name b))
+ − 1251 (princ "(killed)" stream))
+ − 1252 (t
+ − 1253 (princ (buffer-name b) stream))))
+ − 1254 (indent-to 37 1) ;####
+ − 1255 (let ((tn (process-tty-name p)))
+ − 1256 (cond ((not tn)
+ − 1257 (princ "(none)" stream))
+ − 1258 (t
+ − 1259 (princ (format "%s" tn) stream))))
+ − 1260 (indent-to 49 1) ;####
+ − 1261 (if (not (integerp pid))
+ − 1262 (progn
+ − 1263 (princ "network stream connection " stream)
+ − 1264 (princ (car pid) stream)
+ − 1265 (princ "@" stream)
+ − 1266 (princ (cdr pid) stream))
+ − 1267 (let ((cmd (process-command p)))
+ − 1268 (while cmd
+ − 1269 (princ (car cmd) stream)
+ − 1270 (setq cmd (cdr cmd))
+ − 1271 (if cmd (princ " " stream)))))
+ − 1272 (terpri stream)))))))