[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Feature request: show property 'permanent-local t in describe-variab
From: |
martin rudalics |
Subject: |
Re: Feature request: show property 'permanent-local t in describe-variable |
Date: |
Tue, 04 Dec 2007 11:10:20 +0100 |
User-agent: |
Mozilla Thunderbird 1.0 (Windows/20041206) |
I'd propose to do the following:
(1) Do away with `variable-binding-locus'.
(2) Modify `describe-variable' and the affected functions in edebug.el
accordingly.
Any objections against the attached patch?
*** help-fns.el.~1.109.~ Sat Nov 10 10:30:54 2007
--- help-fns.el Tue Dec 4 10:43:34 2007
***************
*** 478,489 ****
output))
;;;###autoload
! (defun describe-variable (variable &optional buffer frame)
"Display the full documentation of VARIABLE (a symbol).
! Returns the documentation as a string, also.
! If VARIABLE has a buffer-local value in BUFFER or FRAME
! \(default to the current buffer and current frame),
! it is displayed along with the global value."
(interactive
(let ((v (variable-at-point))
(enable-recursive-minibuffers t)
--- 478,488 ----
output))
;;;###autoload
! (defun describe-variable (variable &optional buffer)
"Display the full documentation of VARIABLE (a symbol).
! Returns the documentation as a string, also. If VARIABLE has a
! buffer-local value in BUFFER \(default is current buffer), it is
! displayed along with the global value."
(interactive
(let ((v (variable-at-point))
(enable-recursive-minibuffers t)
***************
*** 501,519 ****
(list (if (equal val "")
v (intern val)))))
(unless (buffer-live-p buffer) (setq buffer (current-buffer)))
- (unless (frame-live-p frame) (setq frame (selected-frame)))
(if (not (symbolp variable))
(message "You did not specify a variable")
(save-excursion
(let ((valvoid (not (with-current-buffer buffer (boundp variable))))
! val val-start-pos locus)
;; Extract the value before setting up the output buffer,
;; in case `buffer' *is* the output buffer.
(unless valvoid
! (with-selected-frame frame
! (with-current-buffer buffer
! (setq val (symbol-value variable)
! locus (variable-binding-locus variable)))))
(help-setup-xref (list #'describe-variable variable buffer)
(interactive-p))
(with-help-window (help-buffer)
--- 500,516 ----
(list (if (equal val "")
v (intern val)))))
(unless (buffer-live-p buffer) (setq buffer (current-buffer)))
(if (not (symbolp variable))
(message "You did not specify a variable")
(save-excursion
(let ((valvoid (not (with-current-buffer buffer (boundp variable))))
! val val-start-pos is-local)
;; Extract the value before setting up the output buffer,
;; in case `buffer' *is* the output buffer.
(unless valvoid
! (with-current-buffer buffer
! (setq val (symbol-value variable))
! (setq is-local (local-variable-p variable buffer))))
(help-setup-xref (list #'describe-variable variable buffer)
(interactive-p))
(with-help-window (help-buffer)
***************
*** 575,587 ****
(delete-region (1- from) from)))))
(terpri)
! (when locus
! (if (bufferp locus)
! (princ (format "%socal in buffer %s; "
! (if (get variable 'permanent-local)
! "Permanently l" "L")
! (buffer-name)))
! (princ (format "It is a frame-local variable; ")))
(if (not (default-boundp variable))
(princ "globally void")
(let ((val (default-value variable)))
--- 572,582 ----
(delete-region (1- from) from)))))
(terpri)
! (when is-local
! (princ (format "%socal in buffer %s; "
! (if (get variable 'permanent-local)
! "Permanently l" "L")
! (buffer-name)))
(if (not (default-boundp variable))
(princ "globally void")
(let ((val (default-value variable)))
***************
*** 598,604 ****
;; (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.
(with-current-buffer standard-output
--- 593,599 ----
;; (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.
(with-current-buffer standard-output
***************
*** 626,645 ****
(terpri)
(let* ((alias (condition-case nil
! (indirect-variable variable)
! (error variable)))
(obsolete (get variable 'byte-obsolete-variable))
(safe-var (get variable 'safe-local-variable))
(doc (or (documentation-property variable
'variable-documentation)
(documentation-property alias
'variable-documentation)))
(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))))
(setq extra-line t)
! (princ " Automatically becomes buffer-local when set in any
fashion.\n"))
;; Mention if it's an alias
(unless (eq alias variable)
--- 621,643 ----
(terpri)
(let* ((alias (condition-case nil
! (indirect-variable variable)
! (error variable)))
(obsolete (get variable 'byte-obsolete-variable))
(safe-var (get variable 'safe-local-variable))
(doc (or (documentation-property variable
'variable-documentation)
(documentation-property alias
'variable-documentation)))
(extra-line nil))
;; Add a note for variables that have been
make-var-buffer-local.
! (when (and (not is-local)
! (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 (format " Automatically becomes %sbuffer-local when set
in any fashion.\n"
! (if (get variable 'permanent-local)
! "permanently " ""))))
;; Mention if it's an alias
(unless (eq alias variable)
*** emacs-lisp/edebug.el.~3.102.~ Mon Oct 15 08:58:22 2007
--- emacs-lisp/edebug.el Tue Dec 4 10:31:42 2007
***************
*** 2333,2358 ****
"Return a cons cell describing the status of VAR's current binding.
The purpose of this function is so you can properly undo
subsequent changes to the same binding, by passing the status
! cons cell to `edebug-restore-status'. The status cons cell
! has the form (LOCUS . VALUE), where LOCUS can be a buffer
! \(for a buffer-local binding), a frame (for a frame-local binding),
! or nil (if the default binding is current)."
! (cons (variable-binding-locus var)
(symbol-value var)))
(defun edebug-restore-status (var status)
"Reset VAR based on STATUS.
STATUS should be a list you got from `edebug-var-status'."
! (let ((locus (car status))
(value (cdr status)))
! (cond ((bufferp locus)
! (if (buffer-live-p locus)
! (with-current-buffer locus
! (set var value))))
! ((framep locus)
! (modify-frame-parameters locus (list (cons var value))))
! (t
! (set var value)))))
(defun edebug-enter-trace (edebug-body)
(let ((edebug-stack-depth (1+ edebug-stack-depth))
--- 2333,2354 ----
"Return a cons cell describing the status of VAR's current binding.
The purpose of this function is so you can properly undo
subsequent changes to the same binding, by passing the status
! cons cell to `edebug-restore-status'. The status cons cell has
! the form (BUFFER . VALUE), where BUFFER must specify a buffer
! \(for a buffer-local binding), or nil (if the default binding is
! current)."
! (cons (when (local-variable-p var) (current-buffer))
(symbol-value var)))
(defun edebug-restore-status (var status)
"Reset VAR based on STATUS.
STATUS should be a list you got from `edebug-var-status'."
! (let ((buffer (car status))
(value (cdr status)))
! (if (buffer-live-p buffer)
! (with-current-buffer buffer
! (set var value))
! (set var value))))
(defun edebug-enter-trace (edebug-body)
(let ((edebug-stack-depth (1+ edebug-stack-depth))
*** data.c.~1.281.~ Fri Oct 26 23:52:22 2007
--- data.c Tue Dec 4 10:25:48 2007
***************
*** 1849,1888 ****
return Qnil;
}
- DEFUN ("variable-binding-locus", Fvariable_binding_locus,
Svariable_binding_locus,
- 1, 1, 0,
- doc: /* Return a value indicating where VARIABLE's current binding
comes from.
- If the current binding is buffer-local, the value is the current buffer.
- If the current binding is frame-local, the value is the selected frame.
- If the current binding is global (the default), the value is nil. */)
- (variable)
- register Lisp_Object variable;
- {
- Lisp_Object valcontents;
-
- CHECK_SYMBOL (variable);
- variable = indirect_variable (variable);
-
- /* Make sure the current binding is actually swapped in. */
- find_symbol_value (variable);
-
- valcontents = XSYMBOL (variable)->value;
-
- if (BUFFER_LOCAL_VALUEP (valcontents)
- || BUFFER_OBJFWDP (valcontents))
- {
- /* For a local variable, record both the symbol and which
- buffer's or frame's value we are saving. */
- if (!NILP (Flocal_variable_p (variable, Qnil)))
- return Fcurrent_buffer ();
- else if (BUFFER_LOCAL_VALUEP (valcontents)
- && XBUFFER_LOCAL_VALUE (valcontents)->found_for_frame)
- return XBUFFER_LOCAL_VALUE (valcontents)->frame;
- }
-
- return Qnil;
- }
-
/* This code is disabled now that we use the selected frame to return
keyboard-local-values. */
#if 0
--- 1849,1854 ----
***************
*** 3385,3391 ****
defsubr (&Smake_variable_frame_local);
defsubr (&Slocal_variable_p);
defsubr (&Slocal_variable_if_set_p);
- defsubr (&Svariable_binding_locus);
#if 0 /* XXX Remove this. --lorentey */
defsubr (&Sterminal_local_value);
defsubr (&Sset_terminal_local_value);
--- 3351,3356 ----