unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Kevin Rodgers <ihs_4664@yahoo.com>
Subject: Re: [drew.adams@oracle.com: links in Help buffer aren'talwayscorrect]
Date: Mon, 19 Dec 2005 11:22:08 -0800 (PST)	[thread overview]
Message-ID: <20051219192208.31866.qmail@web51011.mail.yahoo.com> (raw)
In-Reply-To: <E1EnQVb-00056d-Vz@fencepost.gnu.org>

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

"Richard M. Stallman" <rms@gnu.org> wrote:
> It looks like this code extracts the list of frame parameter names
> when it is _loaded_.  That is inconvenient.  Could you 
> do that when the function is called for the first time?
...
> replace-regexp is meant for users; could you please write a simple
> while loop instead?

Sure, this version fixes both concerns.
-- 
Kevin

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 2803423440-describe-frame-parameter.el --]
[-- Type: text/x-emacs-lisp; name="describe-frame-parameter.el", Size: 4608 bytes --]

(defvar frame-parameter-docstring-alist nil
  "List of (PARAMETER . DOC-STRING) associations.")

(defun default-frame-parameter-docstring-alist ()
  "Return the default value of `frame-parameter-docstring-alist'."
  (save-excursion
    (save-window-excursion
      (let ((alist '())
            (pop-up-frames nil))
        (info "(elisp)Window Frame Parameters")
        (goto-char (point-min))
        (while (re-search-forward "^`\\(\\sw\\(?:\\sw\\|\\s_\\)*\\)'$" nil t)
          (let* ((parameter (intern (match-string 1)))
                 (infostring
                  (buffer-substring (1+ (point))
                                    (1- (or (re-search-forward "^`" nil t)
                                            (point-max)))))
                 (case-fold-search t)
                 (xref-regexp
                  "\\(?: (\\|; see \\)?\\*note[ \t\n]*\\(?:[^:]*\\)::[).]")
                 (xref-or-indent-regexp
                  (format "\\(%s\\)\\|\\(\n +\\)" xref-regexp))
                 (docstring
                  ;; delete Info xrefs and indentation, then reformat:
                  (with-temp-buffer
                    (insert infostring)
                    (goto-char (point-min))
                    (while (re-search-forward xref-or-indent-regexp nil t)
                      (cond ((and (match-beginning 1) (match-end 1))
                             (replace-match "" t t))
                            ((and (match-beginning 2) (match-end 2))
                             (replace-match "\n" t t))))
                    (fill-region (point-min) (point-max))
                    (buffer-string))))
            (setq alist
                  (cons (cons parameter docstring)
                        alist))
            ;; move to matched backquote at bol:
            (backward-char 1)))
        (nreverse alist)))))

(defun describe-frame-parameter (parameter &optional frame)
  "Display the full documentation of frame PARAMETER (a symbol) in FRAME.
If FRAME is nil, describe the selected frame's parameter value."
  (interactive
   (let* ((enable-recursive-minibuffers t)
          (default-param (symbol-at-point))
          ;; in Emacs 21.4 there are 41 documented frame parameters; 83
          ;; is the smallest prime that's at least twice that:
          (param-table (let ((table (make-vector 83 0)))
                         (mapc (lambda (assoc)
                                 (intern (symbol-name (car assoc)) table))
                               (or frame-parameter-docstring-alist
                                   (setq frame-parameter-docstring-alist
                                         (default-frame-parameter-docstring-alist))))
                         (mapc (lambda (assoc)
                                 (intern (symbol-name (car assoc)) table))
                               (frame-parameters nil))
                         table))
          (param-name
           (progn
             ;; make sure the default is a frame parameter:
             (setq default-param
                   (intern-soft (symbol-name default-param) param-table))
             ;; complete on both documented frame parameters and
             ;; user-defined parameters that may be set:
             (completing-read (if default-param
                                  (format "Describe parameter (default %s): "
                                          default-param)
                                "Describe parameter: ")
                              param-table
                              nil t nil nil
                              (if default-param (symbol-name default-param))))))
     (list (if (equal param-name "")
               default-param
             (intern param-name)))))
  (if (null frame)
      (setq frame (selected-frame)))
  (if (null parameter)
      (message "You did not specify a frame parameter")
    (let ((value (frame-parameter frame parameter))
          (docstring (cdr (assq parameter frame-parameter-docstring-alist))))
      (with-output-to-temp-buffer "*Help*"
        (prin1 parameter)
        (princ "'s value is ")
        (terpri)
        (with-current-buffer standard-output
          (let ((from (point)))
            (pp value)
            ;; (help-xref-on-pp from (point))
            (if (< (point) (+ from 20))
                (save-excursion
                  (goto-char from)
                  (delete-char -1)))))
        (terpri)
        (terpri)
        (princ "Documentation:")
        (terpri)
        (if docstring
            (princ docstring)
          (princ "not documented as a frame parameter."))))))

[-- 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:[~2005-12-19 19:22 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <E1EnQVb-00056d-Vz@fencepost.gnu.org>
2005-12-19 19:22 ` Kevin Rodgers [this message]
2005-12-20 19:10   ` [drew.adams@oracle.com: links in Help buffer aren'talwayscorrect] Kevin Rodgers
2005-12-20 19:59     ` Stefan Monnier
2005-12-23 17:07   ` Kevin Rodgers
2005-12-23 17:47     ` Eli Zaretskii
     [not found] <E1Eoa6a-0004hk-QI@fencepost.gnu.org>
2005-12-20 16:09 ` Kevin Rodgers
2005-12-14 20:02 [drew.adams@oracle.com: links in Help buffer aren't alwayscorrect] Richard M. Stallman
2005-12-14 22:48 ` [drew.adams@oracle.com: links in Help buffer aren'talwayscorrect] Drew Adams
2005-12-15  1:11   ` Kevin Rodgers
2005-12-15  3:16     ` Stefan Monnier
2005-12-15 17:08     ` Richard M. Stallman
2005-12-15  4:39   ` Eli Zaretskii
2005-12-15 17:08   ` Richard M. Stallman
2005-12-16 18:53     ` Kevin Rodgers

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=20051219192208.31866.qmail@web51011.mail.yahoo.com \
    --to=ihs_4664@yahoo.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).