unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: martin rudalics <rudalics@gmx.at>
To: "Lennart Borgman (gmail)" <lennart.borgman@gmail.com>
Cc: Emacs Devel <emacs-devel@gnu.org>
Subject: Re: Feature request: show property 'permanent-local t	in	describe-variable
Date: Tue, 04 Dec 2007 11:10:20 +0100	[thread overview]
Message-ID: <4755278C.2080704@gmx.at> (raw)
In-Reply-To: <47550C8B.6090904@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 206 bytes --]

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?

[-- Attachment #2: describe-variable.patch --]
[-- Type: text/plain, Size: 10145 bytes --]

*** 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 ----

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

  reply	other threads:[~2007-12-04 10:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-03 20:48 Feature request: show property 'permanent-local t in describe-variable Lennart Borgman (gmail)
2007-12-03 22:04 ` martin rudalics
2007-12-03 22:49   ` Lennart Borgman (gmail)
2007-12-03 22:54     ` Lennart Borgman (gmail)
2007-12-04  7:39       ` martin rudalics
2007-12-04  8:15         ` Lennart Borgman (gmail)
2007-12-04 10:10           ` martin rudalics [this message]
2007-12-04 15:30             ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4755278C.2080704@gmx.at \
    --to=rudalics@gmx.at \
    --cc=emacs-devel@gnu.org \
    --cc=lennart.borgman@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).