Mercurial > emacs
comparison lisp/help-fns.el @ 45975:7ea38f55545b
(describe-variable): Only use `buffer' is still live.
Use `delete-region' instead of save-excursion + delete-char.
Document the obsolescence of the variable, if applicable.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Sun, 23 Jun 2002 21:02:45 +0000 |
parents | 3431e29f1d9c |
children | 0e4c329e9ab6 |
comparison
equal
deleted
inserted
replaced
45974:ea7ac7c7747b | 45975:7ea38f55545b |
---|---|
1 ;;; help-fns.el --- Complex help functions | 1 ;;; help-fns.el --- Complex help functions |
2 | 2 |
3 ;; Copyright (C) 1985, 1986, 1993, 1994, 1998, 1999, 2000, 2001 | 3 ;; Copyright (C) 1985, 1986, 1993, 1994, 1998, 1999, 2000, 2001, 2002 |
4 ;; Free Software Foundation, Inc. | 4 ;; Free Software Foundation, Inc. |
5 | 5 |
6 ;; Maintainer: FSF | 6 ;; Maintainer: FSF |
7 ;; Keywords: help, internal | 7 ;; Keywords: help, internal |
8 | 8 |
113 nil nil | 113 nil nil |
114 t)) | 114 t)) |
115 (catch 'answer | 115 (catch 'answer |
116 (dolist (dir (or path load-path)) | 116 (dolist (dir (or path load-path)) |
117 (dolist (suf (append (unless nosuffix load-suffixes) '(""))) | 117 (dolist (suf (append (unless nosuffix load-suffixes) '(""))) |
118 (let ((try (expand-file-name (concat library suf) dir))) | 118 (let ((try (expand-file-name (concat library suf) dir))) |
119 (and (file-readable-p try) | 119 (and (file-readable-p try) |
120 (null (file-directory-p try)) | 120 (null (file-directory-p try)) |
121 (progn | 121 (progn |
122 (if interactive-call | 122 (if interactive-call |
123 (message "Library is file %s" (abbreviate-file-name try))) | 123 (message "Library is file %s" (abbreviate-file-name try))) |
213 (when (equal file-name "loaddefs.el") | 213 (when (equal file-name "loaddefs.el") |
214 ;; Find the real def site of the preloaded function. | 214 ;; Find the real def site of the preloaded function. |
215 ;; This is necessary only for defaliases. | 215 ;; This is necessary only for defaliases. |
216 (let ((location | 216 (let ((location |
217 (condition-case nil | 217 (condition-case nil |
218 (find-function-search-for-symbol function nil "loaddefs.el") | 218 (find-function-search-for-symbol function nil "loaddefs.el") |
219 (error nil)))) | 219 (error nil)))) |
220 (when location | 220 (when location |
221 (with-current-buffer (car location) | 221 (with-current-buffer (car location) |
222 (goto-char (cdr location)) | 222 (goto-char (cdr location)) |
223 (when (re-search-backward | 223 (when (re-search-backward |
348 "Describe variable: ") | 348 "Describe variable: ") |
349 obarray 'boundp t nil nil | 349 obarray 'boundp t nil nil |
350 (if (symbolp v) (symbol-name v)))) | 350 (if (symbolp v) (symbol-name v)))) |
351 (list (if (equal val "") | 351 (list (if (equal val "") |
352 v (intern val))))) | 352 v (intern val))))) |
353 (unless (bufferp buffer) (setq buffer (current-buffer))) | 353 (unless (buffer-live-p buffer) (setq buffer (current-buffer))) |
354 (if (not (symbolp variable)) | 354 (if (not (symbolp variable)) |
355 (message "You did not specify a variable") | 355 (message "You did not specify a variable") |
356 (save-excursion | 356 (save-excursion |
357 (let (valvoid) | 357 (let (valvoid) |
358 (help-setup-xref (list #'describe-variable variable buffer) | 358 (help-setup-xref (list #'describe-variable variable buffer) |
390 ;; sensible size before prettyprinting. -- fx | 390 ;; sensible size before prettyprinting. -- fx |
391 (let ((from (point))) | 391 (let ((from (point))) |
392 (pp val) | 392 (pp val) |
393 (help-xref-on-pp from (point)) | 393 (help-xref-on-pp from (point)) |
394 (if (< (point) (+ from 20)) | 394 (if (< (point) (+ from 20)) |
395 (save-excursion | 395 (delete-region (1- from) from)))))) |
396 (goto-char from) | |
397 (delete-char -1))))))) | |
398 (terpri)) | 396 (terpri)) |
399 (terpri) | 397 (terpri) |
400 (with-current-buffer standard-output | 398 (with-current-buffer standard-output |
401 (when (> (count-lines (point-min) (point-max)) 10) | 399 (when (> (count-lines (point-min) (point-max)) 10) |
402 ;; Note that setting the syntax table like below | 400 ;; Note that setting the syntax table like below |
419 (save-excursion | 417 (save-excursion |
420 (forward-line -1) | 418 (forward-line -1) |
421 (insert "Automatically becomes buffer-local when set in any fashion.\n")))) | 419 (insert "Automatically becomes buffer-local when set in any fashion.\n")))) |
422 (princ "Documentation:") | 420 (princ "Documentation:") |
423 (terpri) | 421 (terpri) |
422 (let ((obsolete (get variable 'byte-obsolete-variable))) | |
423 (when obsolete | |
424 (princ "This variable is obsolete") | |
425 (if (cdr obsolete) (princ (format " since %s" (cdr obsolete)))) | |
426 (princ ".") (terpri) | |
427 (princ (if (stringp (car obsolete)) (car obsolete) | |
428 (format "Use `%s' instead." (car obsolete)))) | |
429 (terpri))) | |
424 (let ((doc (documentation-property variable 'variable-documentation))) | 430 (let ((doc (documentation-property variable 'variable-documentation))) |
425 (princ (or doc "not documented as a variable."))) | 431 (princ (or doc "not documented as a variable."))) |
426 | 432 |
427 ;; Make a link to customize if this variable can be customized. | 433 ;; Make a link to customize if this variable can be customized. |
428 ;; Note, it is not reliable to test only for a custom-type property | 434 ;; Note, it is not reliable to test only for a custom-type property |