From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#16766: Bad macro expansion of (define-minor-mode electric-indent-local-mode ...) Date: Sat, 15 Feb 2014 21:41:09 +0000 Message-ID: <20140215214109.GA24019@acm.acm> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1392500779 23551 80.91.229.3 (15 Feb 2014 21:46:19 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 15 Feb 2014 21:46:19 +0000 (UTC) To: 16766@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Feb 15 22:46:25 2014 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 1WEn43-0001ax-VE for geb-bug-gnu-emacs@m.gmane.org; Sat, 15 Feb 2014 22:46:24 +0100 Original-Received: from localhost ([::1]:58669 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WEn43-0001gl-KE for geb-bug-gnu-emacs@m.gmane.org; Sat, 15 Feb 2014 16:46:23 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51243) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WEn3s-0001gd-2S for bug-gnu-emacs@gnu.org; Sat, 15 Feb 2014 16:46:21 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WEn3i-00075i-LC for bug-gnu-emacs@gnu.org; Sat, 15 Feb 2014 16:46:12 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:52661) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WEn3i-00075d-He for bug-gnu-emacs@gnu.org; Sat, 15 Feb 2014 16:46:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1WEn3h-0005lS-Uo for bug-gnu-emacs@gnu.org; Sat, 15 Feb 2014 16:46:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 15 Feb 2014 21:46:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 16766 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.139250070822082 (code B ref -1); Sat, 15 Feb 2014 21:46:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 15 Feb 2014 21:45:08 +0000 Original-Received: from localhost ([127.0.0.1]:53840 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WEn2o-0005k4-Jc for submit@debbugs.gnu.org; Sat, 15 Feb 2014 16:45:07 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:49218) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WEn2m-0005jK-5o for submit@debbugs.gnu.org; Sat, 15 Feb 2014 16:45:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WEn2X-0006d3-L5 for submit@debbugs.gnu.org; Sat, 15 Feb 2014 16:44:58 -0500 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:47871) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WEn2X-0006cy-Hd for submit@debbugs.gnu.org; Sat, 15 Feb 2014 16:44:49 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50916) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WEn2Q-0000zI-1C for bug-gnu-emacs@gnu.org; Sat, 15 Feb 2014 16:44:49 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WEn2I-0006N8-N3 for bug-gnu-emacs@gnu.org; Sat, 15 Feb 2014 16:44:41 -0500 Original-Received: from colin.muc.de ([193.149.48.1]:43579 helo=mail.muc.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WEn2I-0006KC-CG for bug-gnu-emacs@gnu.org; Sat, 15 Feb 2014 16:44:34 -0500 Original-Received: (qmail 57831 invoked by uid 3782); 15 Feb 2014 21:44:32 -0000 Original-Received: from acm.muc.de (pD95199AD.dip0.t-ipconnect.de [217.81.153.173]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sat, 15 Feb 2014 22:44:31 +0100 Original-Received: (qmail 24089 invoked by uid 1000); 15 Feb 2014 21:41:09 -0000 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-detected-operating-system: by eggs.gnu.org: FreeBSD 8.x X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). 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:85639 Archived-At: With a newly updated trunk, I put the following into *scratch* and evaluated it with C-u C-x C-e: (pp (macroexpand-all '(define-minor-mode electric-indent-local-mode "Toggle `electric-indent-mode' only in this buffer." :variable (buffer-local-value 'electric-indent-mode (current-buffer)) (cond ((eq electric-indent-mode (default-value 'electric-indent-mode)) (kill-local-variable 'electric-indent-mode)) ((not (default-value 'electric-indent-mode)) ;; Locally enabled, but globally disabled. (electric-indent-mode 1) ; Setup the hooks. (setq-default electric-indent-mode nil) ; But keep it globally disabled. ))))) (This is the definition of electric-indent-local-mode from electric.el). The expansion of this code used the variable `v' twice inside a `let*' form. At a guess, the unusual :variable form is responsible. It also seems stupid that the code is messing around with `(current-buffer)' and `(set-buffer)' at all. What's this all about? Here is the expansion: (progn nil (defalias 'electric-indent-local-mode #'(lambda (&optional arg) "Toggle `electric-indent-mode' only in this buffer." (interactive (list (or current-prefix-arg 'toggle))) (let ((last-message (current-message))) (let* ((v <================================== (current-buffer)) (v <================================== (if (eq arg 'toggle) (not (buffer-local-value 'electric-indent-mode (current-buffer))) (> (prefix-numeric-value arg) 0)))) (save-current-buffer (set-buffer v) <================================== (set (make-local-variable 'electric-indent-mode) v))) <=================================== (cond ((eq electric-indent-mode (default-value 'electric-indent-mode)) (kill-local-variable 'electric-indent-mode)) ((not (default-value 'electric-indent-mode)) (electric-indent-mode 1) (setq-default electric-indent-mode nil))) (run-hooks 'electric-indent-local-mode-hook (if (buffer-local-value 'electric-indent-mode (current-buffer)) 'electric-indent-local-mode-on-hook 'electric-indent-local-mode-off-hook)) (if (called-interactively-p 'any) (progn nil (if (and (current-message) (not (equal last-message (current-message)))) nil (message "Electric-Indent-Local mode %sabled" (if (buffer-local-value 'electric-indent-mode (current-buffer)) "en" "dis")))))) (force-mode-line-update) (buffer-local-value 'electric-indent-mode (current-buffer)))) :autoload-end (defvar electric-indent-local-mode-hook nil "Hook run after entering or leaving `(buffer-local-value (quote electric-indent-mode) (current-buffer))'.\nNo problems result if this variable is not bound.\n`add-hook' automatically binds\ it. (This is true for all hook variables.)") nil nil) -- Alan Mackenzie (Nuremberg, Germany).