[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r109440: Improvements to local-variab
From: |
Chong Yidong |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r109440: Improvements to local-variable reporting in `describe-variable'. |
Date: |
Sun, 05 Aug 2012 16:41:12 +0800 |
User-agent: |
Bazaar (2.5.0) |
------------------------------------------------------------
revno: 109440
fixes bug: http://debbugs.gnu.org/6644
committer: Chong Yidong <address@hidden>
branch nick: trunk
timestamp: Sun 2012-08-05 16:41:12 +0800
message:
Improvements to local-variable reporting in `describe-variable'.
* lisp/help-fns.el (describe-variable): Add hyperlink for
directory-local variables files. Improve buffer-local and
permanent-local reporting; suggested by MON KEY.
* lisp/help-mode.el (help-dir-local-var-def): New button type.
modified:
lisp/ChangeLog
lisp/help-fns.el
lisp/help-mode.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2012-08-05 07:45:12 +0000
+++ b/lisp/ChangeLog 2012-08-05 08:41:12 +0000
@@ -1,5 +1,11 @@
2012-08-05 Chong Yidong <address@hidden>
+ * help-fns.el (describe-variable): Add hyperlink for
+ directory-local variables files. Improve buffer-local and
+ permanent-local reporting; suggested by MON KEY (Bug#6644).
+
+ * help-mode.el (help-dir-local-var-def): New button type.
+
* files.el (kill-buffer-hook): Provide a defvar.
2012-08-05 Glenn Morris <address@hidden>
=== modified file 'lisp/help-fns.el'
--- a/lisp/help-fns.el 2012-07-26 01:27:33 +0000
+++ b/lisp/help-fns.el 2012-08-05 08:41:12 +0000
@@ -713,6 +713,7 @@
(message "You did not specify a variable")
(save-excursion
(let ((valvoid (not (with-current-buffer buffer (boundp variable))))
+ (permanent-local (get variable 'permanent-local))
val val-start-pos locus)
;; Extract the value before setting up the output buffer,
;; in case `buffer' *is* the output buffer.
@@ -752,7 +753,6 @@
(princ "value is ")
(let ((from (point))
(line-beg (line-beginning-position))
- ;;
(print-rep
(let ((print-quoted t))
(prin1-to-string val))))
@@ -780,9 +780,7 @@
(when locus
(cond
((bufferp locus)
- (princ (format "%socal in buffer %s; "
- (if (get variable 'permanent-local)
- "Permanently l" "L")
+ (princ (format "Local in buffer %s; "
(buffer-name))))
((framep locus)
(princ (format "It is a frame-local variable; ")))
@@ -792,20 +790,22 @@
(princ (format "It is local to %S" locus))))
(if (not (default-boundp variable))
(princ "globally void")
- (let ((val (default-value variable)))
+ (let ((global-val (default-value variable)))
(with-current-buffer standard-output
(princ "global value is ")
- (terpri)
- ;; Fixme: pp can take an age if you happen to
- ;; ask for a very large expression. We should
- ;; probably print it raw once and check it's a
- ;; sensible size before prettyprinting. -- fx
- (let ((from (point)))
- (pp val)
- ;; See previous comment for this function.
- ;; (help-xref-on-pp from (point))
- (if (< (point) (+ from 20))
- (delete-region (1- from) from))))))
+ (if (eq val global-val)
+ (princ "the same.")
+ (terpri)
+ ;; Fixme: pp can take an age if you happen to
+ ;; ask for a very large expression. We should
+ ;; probably print it raw once and check it's a
+ ;; sensible size before prettyprinting. -- fx
+ (let ((from (point)))
+ (pp global-val)
+ ;; See previous comment for this function.
+ ;; (help-xref-on-pp from (point))
+ (if (< (point) (+ from 20))
+ (delete-region (1- from) from)))))))
(terpri))
;; If the value is large, move it to the end.
@@ -846,18 +846,26 @@
alias 'variable-documentation))
(error (format "Doc not found: %S" err))))
(extra-line nil))
- ;; Add a note for variables that have been make-var-buffer-local.
- (when (and (local-variable-if-set-p variable)
- (or (not (local-variable-p variable))
- (with-temp-buffer
- (local-variable-if-set-p variable))))
+
+ ;; Mention if it's a local variable.
+ (cond
+ ((and (local-variable-if-set-p variable)
+ (or (not (local-variable-p variable))
+ (with-temp-buffer
+ (local-variable-if-set-p variable))))
(setq extra-line t)
(princ " Automatically becomes ")
- (if (get variable 'permanent-local)
+ (if permanent-local
(princ "permanently "))
(princ "buffer-local when set.\n"))
+ ((not permanent-local))
+ ((bufferp locus)
+ (princ " This variable's buffer-local value is permanent.\n"))
+ (t
+ (princ " This variable's value is permanent \
+if it is given a local binding.\n")))
- ;; Mention if it's an alias
+ ;; Mention if it's an alias.
(unless (eq alias variable)
(setq extra-line t)
(princ (format " This variable is an alias for `%s'.\n"
alias)))
@@ -879,9 +887,11 @@
(not (file-remote-p (buffer-file-name)))
(dir-locals-find-file
(buffer-file-name))))
- (type "file"))
- (princ " This variable is a directory local variable")
- (when file
+ (dir-file t))
+ (princ " This variable's value is directory-local")
+ (if (null file)
+ (princ ".\n")
+ (princ ", set ")
(if (consp file) ; result from cache
;; If the cache element has an mtime, we
;; assume it came from a file.
@@ -889,21 +899,27 @@
(setq file (expand-file-name
dir-locals-file (car file)))
;; Otherwise, assume it was set directly.
- (setq type "directory")))
- (princ (format "\n from the %s \"%s\"" type file)))
- (princ ".\n"))
- (princ " This variable is a file local variable.\n")))
+ (setq dir-file nil)))
+ (princ (if dir-file
+ "by the file\n `"
+ "for the directory\n `"))
+ (with-current-buffer standard-output
+ (insert-text-button
+ file 'type 'help-dir-local-var-def
+ 'help-args (list variable file)))
+ (princ "'.\n")))
+ (princ " This variable's value is file-local.\n")))
(when (memq variable ignored-local-variables)
(setq extra-line t)
- (princ " This variable is ignored when used as a file local \
+ (princ " This variable is ignored as a file-local \
variable.\n"))
;; Can be both risky and safe, eg auto-fill-function.
(when (risky-local-variable-p variable)
(setq extra-line t)
- (princ " This variable is potentially risky when used as a \
-file local variable.\n")
+ (princ " This variable may be risky if used as a \
+file-local variable.\n")
(when (assq variable safe-local-variable-values)
(princ " However, you have added it to \
`safe-local-variable-values'.\n")))
=== modified file 'lisp/help-mode.el'
--- a/lisp/help-mode.el 2012-07-13 07:06:09 +0000
+++ b/lisp/help-mode.el 2012-08-05 08:41:12 +0000
@@ -265,6 +265,15 @@
:supertype 'help-xref
'help-function 'customize-create-theme
'help-echo (purecopy "mouse-2, RET: edit this theme file"))
+
+(define-button-type 'help-dir-local-var-def
+ :supertype 'help-xref
+ 'help-function (lambda (var &optional file)
+ ;; FIXME: this should go to the point where the
+ ;; local variable was defined.
+ (find-file file))
+ 'help-echo (purecopy "mouse-2, RET: open directory-local variables file"))
+
(defvar bookmark-make-record-function)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r109440: Improvements to local-variable reporting in `describe-variable'.,
Chong Yidong <=