unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#974: 23.0.60; byte-compilation problem
@ 2008-09-12 23:57 ` Drew Adams
  2008-09-14 13:50   ` martin rudalics
  2008-09-15  8:45   ` bug#974: marked as done (23.0.60; byte-compilation problem) Emacs bug Tracking System
  0 siblings, 2 replies; 4+ messages in thread
From: Drew Adams @ 2008-09-12 23:57 UTC (permalink / raw)
  To: emacs-pretest-bug

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

1. byte-compile the attached file in Emacs 22.2.
 
2. emacs -Q for Emacs 23:
 
In GNU Emacs 23.0.60.1 (i386-mingw-nt5.1.2600)
 of 2008-09-03 on LENNART-69DE564
Windowing system distributor `Microsoft Corp.', version 5.1.2600
configured using `configure --with-gcc (3.4) --no-opt --cflags -Ic:/g/include
-fno-crossjumping'
 
3. M-x load-file bug-desc-var.elc   ; byte-compiled version
 
4. C-h v features
 
You get the Wrong number of arguments error shown below. The attached
file has exactly the Emacs 23 CVS code for `describe-variable' from
2008-09-04, except for the interactive spec and doc string. The only
change was to add another optional argument, which is not referenced
anywhere in the body of the definition.
 
The attached file also includes the Emacs 23 macro definitions of
`with-selected-frame' and `with-help-window' (from the Emacs 23
version cited above), for byte-compilation.
 
I know we don't guarantee that you can byte-compile in Emacs 22 and
use the byte-compiled file in Emacs 23, but it is a shame that this
won't work in this case. I suspect there is a bug somewhere. If not,
I would at least like to understand what's happening.
 
Notice from the end of the backtrace message below that the original
`describe-variable' interactive spec is printed there, not the
interactive spec from the attached file. You can see this from (if
(equal val "") v (intern val)), which is missing from the code in the
attached file. Also, the backtrace includes
("c:/Emacs-23-2008-09-03/lisp/help-fns.elc" . 14258), which refers to
the original code for `describe-variable', not to the attached version.
That does not seem correct, to me.
 
 
 
In GNU Emacs 23.0.60.1 (i386-mingw-nt5.1.2600)
 of 2008-09-03 on LENNART-69DE564
Windowing system distributor `Microsoft Corp.', version 5.1.2600
configured using `configure --with-gcc (3.4) --no-opt --cflags -Ic:/g/include
-fno-crossjumping'
 
Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: ENU
  value of $XMODIFIERS: nil
  locale-coding-system: cp1252
  default-enable-multibyte-characters: t
 
Major mode: Dired by name
 
Minor modes in effect:
  tooltip-mode: t
  tool-bar-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  global-auto-composition-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t
 
Recent input:
<help-echo> M-x l o a d - f <return> b u g - d e s 
<tab> c <return> C-h v f e a t u r e s <return> <help-echo> 
<help-echo> <help-echo> <help-echo> <help-echo> <help-echo> 
<help-echo> <menu-bar> <help-menu> <send-emacs-bug
-report>
 
Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Loading c:/drews-lisp-20/bug-desc-var.elc...done
call-interactively: Wrong number of arguments: #[(variable &optional buffer
frame) "=c6\x18=c7 !=84... <binary stuff skipped>"
[file-name buffer frame variable locus val-start-pos nil buffer-live-p
frame-live-p selected-frame ...] 10 ("c:/Emacs-23-2008-09-03/lisp/help-fns.elc"
. 14258) (let ((v (variable-at-point)) (enable-recursive-minibuffers t) val)
(setq val (completing-read (if (symbolp v) (format "Describe variable (default
%s): " v) "Describe variable: ") obarray (quote (lambda (vv) (or (boundp vv)
(get vv (quote variable-documentation))))) t nil nil (if (symbolp v)
(symbol-name v)))) (list (if (equal val "") v (intern val))))], 4




[-- Attachment #2: bug-desc-var.el --]
[-- Type: application/octet-stream, Size: 11735 bytes --]

;;; In describe-variable:
;;; bug-desc-var.el:207:31:Warning: assignment to free variable `help-window'
;;; bug-desc-var.el:207:31:Warning: reference to free variable
;;;     `help-window-point-marker'
;;; bug-desc-var.el:243:16:Warning: reference to free variable `help-window'

;;; In end of data:
;;; bug-desc-var.el:245:1:Warning: the following functions are not known to be defined: help-buffer,
;;;     find-lisp-object-file-name,
;;;     describe-variable-custom-version-info, help-window-setup

(defmacro with-selected-frame (frame &rest body)
  "Execute the forms in BODY with FRAME as the selected frame.
The value returned is the value of the last form in BODY.
See also `with-temp-buffer'."
  (declare (indent 1) (debug t))
  (let ((old-frame (make-symbol "old-frame"))
        (old-buffer (make-symbol "old-buffer")))
    `(let ((,old-frame (selected-frame))
           (,old-buffer (current-buffer)))
       (unwind-protect
            (progn (select-frame ,frame)
                   ,@body)
         (if (frame-live-p ,old-frame)
             (select-frame ,old-frame))
         (if (buffer-live-p ,old-buffer)
             (set-buffer ,old-buffer))))))

(defmacro with-help-window (buffer-name &rest body)
  "Display buffer BUFFER-NAME in a help window evaluating BODY.
Select help window if the actual value of the user option
`help-window-select' says so.  Return last value in BODY."
  (declare (indent 1) (debug t))
  ;; Bind list-of-frames to `frame-list' and list-of-window-tuples to a
  ;; list of one <window window-buffer window-start window-point> tuple
  ;; for each live window.
  `(let ((list-of-frames (frame-list))
	 (list-of-window-tuples
	  (let (list)
	    (walk-windows
	     (lambda (window)
	       (push (list window (window-buffer window)
			   (window-start window) (window-point window))
		     list))
	     'no-mini t)
	    list)))
     ;; Make `help-window' t to trigger `help-mode-finish' to set
     ;; `help-window' to the actual help window.
     (setq help-window t)
     ;; Make `help-window-point-marker' point nowhere (the only place
     ;; where this should be set to a buffer position is within BODY).
     (set-marker help-window-point-marker nil)
     (prog1
	 ;; Return value returned by `with-output-to-temp-buffer'.
	 (with-output-to-temp-buffer ,buffer-name
	   (progn ,@body))
       (when (windowp help-window)
	 ;; Set up help window.
	 (help-window-setup list-of-frames list-of-window-tuples))
       ;; Reset `help-window' to nil to avoid confusing future calls of
       ;; `help-mode-finish' with plain `with-output-to-temp-buffer'.
       (setq help-window nil))))

(defun describe-variable (variable &optional buffer frame optionp)
  "XXXXXXXXXXXXXXXXXXXXXXXXXX"
  (interactive
   (let ((symb (or (and (fboundp 'symbol-nearest-point) (symbol-nearest-point))
                   (and (symbolp (variable-at-point)) (variable-at-point))))
         (enable-recursive-minibuffers t)
         val)
     (setq val (completing-read "Describe variable: " obarray
                                (if current-prefix-arg
                                    (lambda (vv) (user-variable-p vv))
                                  (lambda (vv)
                                    (or (boundp vv) (get vv 'variable-documentation))))
                                t nil nil (and (symbolp symb) (symbol-name symb))))
     (list (if (equal val "") symb (intern val))
           nil
           nil
           current-prefix-arg)))
  (let (file-name)
    (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)
            (with-current-buffer buffer
              (prin1 variable)
              (setq file-name (find-lisp-object-file-name variable 'defvar))

              (if file-name
                  (progn
                    (princ " is a variable defined in `")
                    (princ (if (eq file-name 'C-source) "C source code" file-name))
                    (princ "'.\n")
                    (with-current-buffer standard-output
                      (save-excursion
                        (re-search-backward "`\\([^`']+\\)'" nil t)
                        (help-xref-button 1 'help-variable-def
                                          variable file-name)))
                    (if valvoid
                        (princ "It is void as a variable.")
                      (princ "Its ")))
                (if valvoid
                    (princ " is void as a variable.")
                  (princ "'s "))))
            (if valvoid
                nil
              (with-current-buffer standard-output
                (setq val-start-pos (point))
                (princ "value is ")
                (terpri)
                (let ((from (point)))
                  (pp val)
                  ;; Hyperlinks in variable's value are quite frequently
                  ;; inappropriate e.g C-h v <RET> features <RET>
                  ;; (help-xref-on-pp from (point))
                  (if (< (point) (+ from 20))
                      (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)))
                  (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))))))
              (terpri))

            ;; If the value is large, move it to the end.
            (with-current-buffer standard-output
              (when (> (count-lines (point-min) (point-max)) 10)
                ;; Note that setting the syntax table like below
                ;; makes forward-sexp move over a `'s' at the end
                ;; of a symbol.
                (set-syntax-table emacs-lisp-mode-syntax-table)
                (goto-char val-start-pos)
                ;; The line below previously read as
                ;; (delete-region (point) (progn (end-of-line) (point)))
                ;; which suppressed display of the buffer local value for
                ;; large values.
                (when (looking-at "value is") (replace-match ""))
                (save-excursion
                  (insert "\n\nValue:")
                  (set (make-local-variable 'help-button-cache)
                       (point-marker)))
                (insert "value is shown ")
                (insert-button "below"
                               'action help-button-cache
                               'follow-link t
                               'help-echo "mouse-2, RET: show value")
                (insert ".\n")))
            (terpri)

            (let* ((alias (condition-case nil
                              (indirect-variable variable)
                            (error variable)))
                   (obsolete (get variable 'byte-obsolete-variable))
                   (use (car obsolete))
                   (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)
                (setq extra-line t)
                (princ (format "  This variable is an alias for `%s'.\n" alias)))

              (when obsolete
                (setq extra-line t)
                (princ "  This variable is obsolete")
                (if (cdr obsolete) (princ (format " since %s" (cdr obsolete))))
                (princ (cond ((stringp use) (concat ";\n  " use))
                             (use (format ";\n  use `%s' instead." (car obsolete)))
                             (t ".")))
                (terpri))
              (when safe-var
                (setq extra-line t)
                (princ "  This variable is safe as a file local variable ")
                (princ "if its value\n  satisfies the predicate ")
                (princ (if (byte-code-function-p safe-var)
                           "which is byte-compiled expression.\n"
                         (format "`%s'.\n" safe-var))))

              (if extra-line (terpri))
              (princ "Documentation:\n")
              (with-current-buffer standard-output
                (insert (or doc "Not documented as a variable."))))

            ;; Make a link to customize if this variable can be customized.
            (when (custom-variable-p variable)
              (let ((customize-label "customize"))
                (terpri)
                (terpri)
                (princ (concat "You can " customize-label " this variable."))
                (with-current-buffer standard-output
                  (save-excursion
                    (re-search-backward
                     (concat "\\(" customize-label "\\)") nil t)
                    (help-xref-button 1 'help-customize-variable variable))))
              ;; Note variable's version or package version
              (let ((output (describe-variable-custom-version-info variable)))
                (when output
                  (terpri)
                  (terpri)
                  (princ output))))

            (save-excursion
              (set-buffer standard-output)
              ;; Return the text we displayed.
              (buffer-string))))))))


^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#974: 23.0.60; byte-compilation problem
  2008-09-12 23:57 ` bug#974: 23.0.60; byte-compilation problem Drew Adams
@ 2008-09-14 13:50   ` martin rudalics
  2008-09-14 20:33     ` Drew Adams
  2008-09-15  8:45   ` bug#974: marked as done (23.0.60; byte-compilation problem) Emacs bug Tracking System
  1 sibling, 1 reply; 4+ messages in thread
From: martin rudalics @ 2008-09-14 13:50 UTC (permalink / raw)
  To: Drew Adams, 974

 > 1. byte-compile the attached file in Emacs 22.2.
 >
 > 2. emacs -Q for Emacs 23:
 >
 > In GNU Emacs 23.0.60.1 (i386-mingw-nt5.1.2600)
 >  of 2008-09-03 on LENNART-69DE564
 > Windowing system distributor `Microsoft Corp.', version 5.1.2600
 > configured using `configure --with-gcc (3.4) --no-opt --cflags -Ic:/g/include
 > -fno-crossjumping'
 >
 > 3. M-x load-file bug-desc-var.elc   ; byte-compiled version
 >
 > 4. C-h v features

I'd simply put a (require 'help-fns) _before_ the definition of
`describe-variable' in bug-desc-var.el.

martin






^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#974: 23.0.60; byte-compilation problem
  2008-09-14 13:50   ` martin rudalics
@ 2008-09-14 20:33     ` Drew Adams
  0 siblings, 0 replies; 4+ messages in thread
From: Drew Adams @ 2008-09-14 20:33 UTC (permalink / raw)
  To: 'martin rudalics', 974

>  > 1. byte-compile the attached file in Emacs 22.2.
>  > 2. emacs -Q for Emacs 23:
>  > 3. M-x load-file bug-desc-var.elc ; byte-compiled version
>  > 4. C-h v features
> 
> I'd simply put a (require 'help-fns) _before_ the definition of
> `describe-variable' in bug-desc-var.el.

Very weird. 

I already have (require 'help-fns) in the original file in which I came across
the bug (and before the definition).

But I can't reproduce the problem now - so no bug. Dunno what I did before, but
it must have been user error somehow. ;-) Sorry for the noise.

Thx - Drew







^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#974: marked as done (23.0.60; byte-compilation problem)
  2008-09-12 23:57 ` bug#974: 23.0.60; byte-compilation problem Drew Adams
  2008-09-14 13:50   ` martin rudalics
@ 2008-09-15  8:45   ` Emacs bug Tracking System
  1 sibling, 0 replies; 4+ messages in thread
From: Emacs bug Tracking System @ 2008-09-15  8:45 UTC (permalink / raw)
  To: martin rudalics

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


Your message dated Mon, 15 Sep 2008 10:34:07 +0200
with message-id <48CE1DFF.7010407@gmx.at>
and subject line Re: bug#974: 23.0.60; byte-compilation problem
has caused the Emacs bug report #974,
regarding 23.0.60; byte-compilation problem
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact don@donarmstrong.com
immediately.)


-- 
974: http://emacsbugs.donarmstrong.com/cgi-bin/bugreport.cgi?bug=974
Emacs Bug Tracking System
Contact don@donarmstrong.com with problems

[-- Attachment #2: Type: message/rfc822, Size: 19192 bytes --]

[-- Attachment #2.1.1: Type: text/plain, Size: 3751 bytes --]

1. byte-compile the attached file in Emacs 22.2.
 
2. emacs -Q for Emacs 23:
 
In GNU Emacs 23.0.60.1 (i386-mingw-nt5.1.2600)
 of 2008-09-03 on LENNART-69DE564
Windowing system distributor `Microsoft Corp.', version 5.1.2600
configured using `configure --with-gcc (3.4) --no-opt --cflags -Ic:/g/include
-fno-crossjumping'
 
3. M-x load-file bug-desc-var.elc   ; byte-compiled version
 
4. C-h v features
 
You get the Wrong number of arguments error shown below. The attached
file has exactly the Emacs 23 CVS code for `describe-variable' from
2008-09-04, except for the interactive spec and doc string. The only
change was to add another optional argument, which is not referenced
anywhere in the body of the definition.
 
The attached file also includes the Emacs 23 macro definitions of
`with-selected-frame' and `with-help-window' (from the Emacs 23
version cited above), for byte-compilation.
 
I know we don't guarantee that you can byte-compile in Emacs 22 and
use the byte-compiled file in Emacs 23, but it is a shame that this
won't work in this case. I suspect there is a bug somewhere. If not,
I would at least like to understand what's happening.
 
Notice from the end of the backtrace message below that the original
`describe-variable' interactive spec is printed there, not the
interactive spec from the attached file. You can see this from (if
(equal val "") v (intern val)), which is missing from the code in the
attached file. Also, the backtrace includes
("c:/Emacs-23-2008-09-03/lisp/help-fns.elc" . 14258), which refers to
the original code for `describe-variable', not to the attached version.
That does not seem correct, to me.
 
 
 
In GNU Emacs 23.0.60.1 (i386-mingw-nt5.1.2600)
 of 2008-09-03 on LENNART-69DE564
Windowing system distributor `Microsoft Corp.', version 5.1.2600
configured using `configure --with-gcc (3.4) --no-opt --cflags -Ic:/g/include
-fno-crossjumping'
 
Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: ENU
  value of $XMODIFIERS: nil
  locale-coding-system: cp1252
  default-enable-multibyte-characters: t
 
Major mode: Dired by name
 
Minor modes in effect:
  tooltip-mode: t
  tool-bar-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  global-auto-composition-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t
 
Recent input:
<help-echo> M-x l o a d - f <return> b u g - d e s 
<tab> c <return> C-h v f e a t u r e s <return> <help-echo> 
<help-echo> <help-echo> <help-echo> <help-echo> <help-echo> 
<help-echo> <menu-bar> <help-menu> <send-emacs-bug
-report>
 
Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Loading c:/drews-lisp-20/bug-desc-var.elc...done
call-interactively: Wrong number of arguments: #[(variable &optional buffer
frame) "=c6\x18=c7 !=84... <binary stuff skipped>"
[file-name buffer frame variable locus val-start-pos nil buffer-live-p
frame-live-p selected-frame ...] 10 ("c:/Emacs-23-2008-09-03/lisp/help-fns.elc"
. 14258) (let ((v (variable-at-point)) (enable-recursive-minibuffers t) val)
(setq val (completing-read (if (symbolp v) (format "Describe variable (default
%s): " v) "Describe variable: ") obarray (quote (lambda (vv) (or (boundp vv)
(get vv (quote variable-documentation))))) t nil nil (if (symbolp v)
(symbol-name v)))) (list (if (equal val "") v (intern val))))], 4




[-- Attachment #2.1.2: bug-desc-var.el --]
[-- Type: application/octet-stream, Size: 11735 bytes --]

;;; In describe-variable:
;;; bug-desc-var.el:207:31:Warning: assignment to free variable `help-window'
;;; bug-desc-var.el:207:31:Warning: reference to free variable
;;;     `help-window-point-marker'
;;; bug-desc-var.el:243:16:Warning: reference to free variable `help-window'

;;; In end of data:
;;; bug-desc-var.el:245:1:Warning: the following functions are not known to be defined: help-buffer,
;;;     find-lisp-object-file-name,
;;;     describe-variable-custom-version-info, help-window-setup

(defmacro with-selected-frame (frame &rest body)
  "Execute the forms in BODY with FRAME as the selected frame.
The value returned is the value of the last form in BODY.
See also `with-temp-buffer'."
  (declare (indent 1) (debug t))
  (let ((old-frame (make-symbol "old-frame"))
        (old-buffer (make-symbol "old-buffer")))
    `(let ((,old-frame (selected-frame))
           (,old-buffer (current-buffer)))
       (unwind-protect
            (progn (select-frame ,frame)
                   ,@body)
         (if (frame-live-p ,old-frame)
             (select-frame ,old-frame))
         (if (buffer-live-p ,old-buffer)
             (set-buffer ,old-buffer))))))

(defmacro with-help-window (buffer-name &rest body)
  "Display buffer BUFFER-NAME in a help window evaluating BODY.
Select help window if the actual value of the user option
`help-window-select' says so.  Return last value in BODY."
  (declare (indent 1) (debug t))
  ;; Bind list-of-frames to `frame-list' and list-of-window-tuples to a
  ;; list of one <window window-buffer window-start window-point> tuple
  ;; for each live window.
  `(let ((list-of-frames (frame-list))
	 (list-of-window-tuples
	  (let (list)
	    (walk-windows
	     (lambda (window)
	       (push (list window (window-buffer window)
			   (window-start window) (window-point window))
		     list))
	     'no-mini t)
	    list)))
     ;; Make `help-window' t to trigger `help-mode-finish' to set
     ;; `help-window' to the actual help window.
     (setq help-window t)
     ;; Make `help-window-point-marker' point nowhere (the only place
     ;; where this should be set to a buffer position is within BODY).
     (set-marker help-window-point-marker nil)
     (prog1
	 ;; Return value returned by `with-output-to-temp-buffer'.
	 (with-output-to-temp-buffer ,buffer-name
	   (progn ,@body))
       (when (windowp help-window)
	 ;; Set up help window.
	 (help-window-setup list-of-frames list-of-window-tuples))
       ;; Reset `help-window' to nil to avoid confusing future calls of
       ;; `help-mode-finish' with plain `with-output-to-temp-buffer'.
       (setq help-window nil))))

(defun describe-variable (variable &optional buffer frame optionp)
  "XXXXXXXXXXXXXXXXXXXXXXXXXX"
  (interactive
   (let ((symb (or (and (fboundp 'symbol-nearest-point) (symbol-nearest-point))
                   (and (symbolp (variable-at-point)) (variable-at-point))))
         (enable-recursive-minibuffers t)
         val)
     (setq val (completing-read "Describe variable: " obarray
                                (if current-prefix-arg
                                    (lambda (vv) (user-variable-p vv))
                                  (lambda (vv)
                                    (or (boundp vv) (get vv 'variable-documentation))))
                                t nil nil (and (symbolp symb) (symbol-name symb))))
     (list (if (equal val "") symb (intern val))
           nil
           nil
           current-prefix-arg)))
  (let (file-name)
    (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)
            (with-current-buffer buffer
              (prin1 variable)
              (setq file-name (find-lisp-object-file-name variable 'defvar))

              (if file-name
                  (progn
                    (princ " is a variable defined in `")
                    (princ (if (eq file-name 'C-source) "C source code" file-name))
                    (princ "'.\n")
                    (with-current-buffer standard-output
                      (save-excursion
                        (re-search-backward "`\\([^`']+\\)'" nil t)
                        (help-xref-button 1 'help-variable-def
                                          variable file-name)))
                    (if valvoid
                        (princ "It is void as a variable.")
                      (princ "Its ")))
                (if valvoid
                    (princ " is void as a variable.")
                  (princ "'s "))))
            (if valvoid
                nil
              (with-current-buffer standard-output
                (setq val-start-pos (point))
                (princ "value is ")
                (terpri)
                (let ((from (point)))
                  (pp val)
                  ;; Hyperlinks in variable's value are quite frequently
                  ;; inappropriate e.g C-h v <RET> features <RET>
                  ;; (help-xref-on-pp from (point))
                  (if (< (point) (+ from 20))
                      (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)))
                  (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))))))
              (terpri))

            ;; If the value is large, move it to the end.
            (with-current-buffer standard-output
              (when (> (count-lines (point-min) (point-max)) 10)
                ;; Note that setting the syntax table like below
                ;; makes forward-sexp move over a `'s' at the end
                ;; of a symbol.
                (set-syntax-table emacs-lisp-mode-syntax-table)
                (goto-char val-start-pos)
                ;; The line below previously read as
                ;; (delete-region (point) (progn (end-of-line) (point)))
                ;; which suppressed display of the buffer local value for
                ;; large values.
                (when (looking-at "value is") (replace-match ""))
                (save-excursion
                  (insert "\n\nValue:")
                  (set (make-local-variable 'help-button-cache)
                       (point-marker)))
                (insert "value is shown ")
                (insert-button "below"
                               'action help-button-cache
                               'follow-link t
                               'help-echo "mouse-2, RET: show value")
                (insert ".\n")))
            (terpri)

            (let* ((alias (condition-case nil
                              (indirect-variable variable)
                            (error variable)))
                   (obsolete (get variable 'byte-obsolete-variable))
                   (use (car obsolete))
                   (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)
                (setq extra-line t)
                (princ (format "  This variable is an alias for `%s'.\n" alias)))

              (when obsolete
                (setq extra-line t)
                (princ "  This variable is obsolete")
                (if (cdr obsolete) (princ (format " since %s" (cdr obsolete))))
                (princ (cond ((stringp use) (concat ";\n  " use))
                             (use (format ";\n  use `%s' instead." (car obsolete)))
                             (t ".")))
                (terpri))
              (when safe-var
                (setq extra-line t)
                (princ "  This variable is safe as a file local variable ")
                (princ "if its value\n  satisfies the predicate ")
                (princ (if (byte-code-function-p safe-var)
                           "which is byte-compiled expression.\n"
                         (format "`%s'.\n" safe-var))))

              (if extra-line (terpri))
              (princ "Documentation:\n")
              (with-current-buffer standard-output
                (insert (or doc "Not documented as a variable."))))

            ;; Make a link to customize if this variable can be customized.
            (when (custom-variable-p variable)
              (let ((customize-label "customize"))
                (terpri)
                (terpri)
                (princ (concat "You can " customize-label " this variable."))
                (with-current-buffer standard-output
                  (save-excursion
                    (re-search-backward
                     (concat "\\(" customize-label "\\)") nil t)
                    (help-xref-button 1 'help-customize-variable variable))))
              ;; Note variable's version or package version
              (let ((output (describe-variable-custom-version-info variable)))
                (when output
                  (terpri)
                  (terpri)
                  (princ output))))

            (save-excursion
              (set-buffer standard-output)
              ;; Return the text we displayed.
              (buffer-string))))))))


[-- Attachment #3: Type: message/rfc822, Size: 2122 bytes --]

From: martin rudalics <rudalics@gmx.at>
To: 974-done@emacsbugs.donarmstrong.com
Cc: Drew Adams <drew.adams@oracle.com>
Subject: Re: bug#974: 23.0.60; byte-compilation problem
Date: Mon, 15 Sep 2008 10:34:07 +0200
Message-ID: <48CE1DFF.7010407@gmx.at>

 >>  > 1. byte-compile the attached file in Emacs 22.2.
 >>  > 2. emacs -Q for Emacs 23:
 >>  > 3. M-x load-file bug-desc-var.elc ; byte-compiled version
 >>  > 4. C-h v features
 >>
 >> I'd simply put a (require 'help-fns) _before_ the definition of
 >> `describe-variable' in bug-desc-var.el.
 >
 > Very weird.
 >
 > I already have (require 'help-fns) in the original file in which I came across
 > the bug (and before the definition).
 >
 > But I can't reproduce the problem now - so no bug. Dunno what I did before, but
 > it must have been user error somehow. ;-) Sorry for the noise.

OK.  Marked as done.

martin



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-09-15  8:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <48CE1DFF.7010407@gmx.at>
2008-09-12 23:57 ` bug#974: 23.0.60; byte-compilation problem Drew Adams
2008-09-14 13:50   ` martin rudalics
2008-09-14 20:33     ` Drew Adams
2008-09-15  8:45   ` bug#974: marked as done (23.0.60; byte-compilation problem) Emacs bug Tracking System

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).