From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Harald Hanche-Olsen Newsgroups: gmane.emacs.bugs Subject: bug#20386: 25.0.50; error when calling sgml-attributes and sgml-tag Date: Thu, 23 Jul 2015 18:28:48 +0200 Message-ID: <55B11640.6030707@math.ntnu.no> References: <87mw22k3wo.fsf@fastmail.fm> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1437669031 5798 80.91.229.3 (23 Jul 2015 16:30:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 23 Jul 2015 16:30:31 +0000 (UTC) To: 20386@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jul 23 18:30:22 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZIJO1-0005KY-HM for geb-bug-gnu-emacs@m.gmane.org; Thu, 23 Jul 2015 18:30:21 +0200 Original-Received: from localhost ([::1]:42127 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZIJO0-0003Zy-Sv for geb-bug-gnu-emacs@m.gmane.org; Thu, 23 Jul 2015 12:30:20 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47516) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZIJNs-0003Sc-Ls for bug-gnu-emacs@gnu.org; Thu, 23 Jul 2015 12:30:18 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZIJNm-0002cu-8y for bug-gnu-emacs@gnu.org; Thu, 23 Jul 2015 12:30:12 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:55955) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZIJNm-0002bU-67 for bug-gnu-emacs@gnu.org; Thu, 23 Jul 2015 12:30:06 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1ZIJNl-000075-4F for bug-gnu-emacs@gnu.org; Thu, 23 Jul 2015 12:30:05 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: <87mw22k3wo.fsf@fastmail.fm> Resent-From: Harald Hanche-Olsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 23 Jul 2015 16:30:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 20386 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 20386-submit@debbugs.gnu.org id=B20386.1437668950345 (code B ref 20386); Thu, 23 Jul 2015 16:30:04 +0000 Original-Received: (at 20386) by debbugs.gnu.org; 23 Jul 2015 16:29:10 +0000 Original-Received: from localhost ([127.0.0.1]:57401 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZIJMr-00005V-KJ for submit@debbugs.gnu.org; Thu, 23 Jul 2015 12:29:10 -0400 Original-Received: from hylle05.itea.ntnu.no ([129.241.56.225]:40828) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZIJMp-00005K-4Y for 20386@debbugs.gnu.org; Thu, 23 Jul 2015 12:29:08 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by hylle05.itea.ntnu.no (Postfix) with ESMTP id 2F414904F4B for <20386@debbugs.gnu.org>; Thu, 23 Jul 2015 18:29:04 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at hylle05.itea.ntnu.no Original-Received: from [IPv6:2001:700:300:1470:ccf9:442e:bf61:6156] (unknown [IPv6:2001:700:300:1470:ccf9:442e:bf61:6156]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: hanche) by hylle05.itea.ntnu.no (Postfix) with ESMTPSA id 36375904F53; Thu, 23 Jul 2015 18:28:49 +0200 (CEST) User-Agent: Postbox 4.0.1 (Macintosh/20150514) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:105092 Archived-At: Since I get bitten by this bug regularly, and little has happened to it, I took it upon myself to suggest a patch. I include it below. I believe the patch is sufficiently small and trivial to not be “legally significant” (I don't have any signed papers on file). One caveat: This will break skeleton-read for code that calls it with a symbol, expecting the symbol to be evaluated, if the symbol also has a function binding. If this is undesirable, replace (functionp prompt) in the patched skeleton-read with (and (functionp prompt) (not (symbolp prompt))). – Harald From 1d8cc12f73b6b7fe7907073e6c34b558cc4f726b Mon Sep 17 00:00:00 2001 From: Harald Hanche-Olsen Date: Thu, 23 Jul 2015 18:09:44 +0200 Subject: [PATCH] Fix bug #20386 --- lisp/skeleton.el | 17 ++++++++++------- lisp/textmodes/sgml-mode.el | 14 +++++++++----- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/lisp/skeleton.el b/lisp/skeleton.el index d23488b..2c017dd 100644 --- a/lisp/skeleton.el +++ b/lisp/skeleton.el @@ -277,7 +277,8 @@ When done with skeleton, but before going back to `_'-point call (defun skeleton-read (prompt &optional initial-input recursive) "Function for reading a string from the minibuffer within skeletons. -PROMPT must be a string or a form that evaluates to a string. +PROMPT must be a string or a function that evaluates to a string. +It may also be a form that evaluates to a string (deprecated). It may contain a `%s' which will be replaced by `skeleton-subprompt'. If non-nil second arg INITIAL-INPUT or variable `input' is a string or cons with index to insert before reading. If third arg RECURSIVE is non-nil @@ -306,12 +307,14 @@ automatically, and you are prompted to fill in the variable parts."))) ;; before point. (save-excursion (insert "\n"))) (unwind-protect - (setq prompt (if (stringp prompt) - (read-string (format prompt skeleton-subprompt) - (setq initial-input - (or initial-input - (symbol-value 'input)))) - (eval prompt))) + (setq prompt (cond ((stringp prompt) + (read-string (format prompt skeleton-subprompt) + (setq initial-input + (or initial-input + (symbol-value 'input))))) + ((functionp prompt) + (funcall prompt)) + (t (eval prompt)))) (or eolp (delete-char 1)))) (if (and recursive diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el index 2ffe9c1..6a14b52 100644 --- a/lisp/textmodes/sgml-mode.el +++ b/lisp/textmodes/sgml-mode.el @@ -759,9 +759,10 @@ If QUIET, do not print a message when there are no attributes for TAG." (insert ?\s) (insert (funcall skeleton-transformation-function (setq attribute - (skeleton-read '(completing-read - "Attribute: " - alist))))) + (skeleton-read (lambda () + (completing-read + "Attribute: " + alist)))))) (if (string= "" attribute) (setq i 0) (sgml-value (assoc (downcase attribute) alist)) @@ -1177,13 +1178,16 @@ See `sgml-tag-alist' for info about attribute rules." (if (and (eq (car alist) t) (not sgml-xml-mode)) (when (cdr alist) (insert "=\"") - (setq alist (skeleton-read '(completing-read "Value: " (cdr alist)))) + (setq alist (skeleton-read (lambda () + (completing-read + "Value: " (cdr alist))))) (if (string< "" alist) (insert alist ?\") (delete-char -2))) (insert "=\"") (if (cdr alist) - (insert (skeleton-read '(completing-read "Value: " alist))) + (insert (skeleton-read (lambda () + (completing-read "Value: " alist)))) (when (null alist) (insert (skeleton-read '(read-string "Value: "))))) (insert ?\")))) -- 2.4.5