From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Kaushal Modi Newsgroups: gmane.emacs.bugs Subject: bug#22819: 25.0.91; Don't try to indent region if the buffer is read-only Date: Mon, 07 Aug 2017 18:02:21 +0000 Message-ID: References: <87vam26amc.fsf@users.sourceforge.net> <83lgmywlo4.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="001a114b123a9ad06f05562da6f4" X-Trace: blaine.gmane.org 1502129012 18902 195.159.176.226 (7 Aug 2017 18:03:32 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 7 Aug 2017 18:03:32 +0000 (UTC) Cc: 22819@debbugs.gnu.org To: Noam Postavsky Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Aug 07 20:03:18 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1demMx-00040U-Nb for geb-bug-gnu-emacs@m.gmane.org; Mon, 07 Aug 2017 20:03:11 +0200 Original-Received: from localhost ([::1]:38765 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1demN3-00026T-Rh for geb-bug-gnu-emacs@m.gmane.org; Mon, 07 Aug 2017 14:03:17 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33691) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1demMt-00025h-NW for bug-gnu-emacs@gnu.org; Mon, 07 Aug 2017 14:03:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1demMo-0000U6-EO for bug-gnu-emacs@gnu.org; Mon, 07 Aug 2017 14:03:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:42009) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1demMo-0000Ty-BG for bug-gnu-emacs@gnu.org; Mon, 07 Aug 2017 14:03:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1demMo-0002Yh-0L for bug-gnu-emacs@gnu.org; Mon, 07 Aug 2017 14:03:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Kaushal Modi Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 07 Aug 2017 18:03:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22819 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 22819-submit@debbugs.gnu.org id=B22819.15021289599801 (code B ref 22819); Mon, 07 Aug 2017 18:03:01 +0000 Original-Received: (at 22819) by debbugs.gnu.org; 7 Aug 2017 18:02:39 +0000 Original-Received: from localhost ([127.0.0.1]:50690 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1demMR-0002Y1-7h for submit@debbugs.gnu.org; Mon, 07 Aug 2017 14:02:39 -0400 Original-Received: from mail-lf0-f45.google.com ([209.85.215.45]:34564) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1demMQ-0002Xp-5C for 22819@debbugs.gnu.org; Mon, 07 Aug 2017 14:02:38 -0400 Original-Received: by mail-lf0-f45.google.com with SMTP id g25so5179155lfh.1 for <22819@debbugs.gnu.org>; Mon, 07 Aug 2017 11:02:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Z7rpR8BkehrhSQ5szTWY+qRfncmTTZsQRTIZSTmWwI8=; b=I1VX5JB0Ei1KLYH7Us70uRAiNIsFGxyioC9Zldy/cPy7kwGBkQgZe31NvTxe/89vl6 nhtdjLzzM7ZRr9fkvVOxXUzu5OnSR1/i7VD656nQyEA+UUwfAdEEgVqJb4JMPSSRn2JH 59GSCRwarY1lPvXpAL1qHJmlS79MO7iwjmligNi07s1PUivQ+dJArIQ4ye+VEZqrrDTS jk2Pv8iRxGA+ST9Uthf2M8hFL/iFdZih5axz5CtZYVgrRKRXy2uYYQPRtyTbeEkavnc+ gWTkjTteN6eBFf/qBX5dB5JXCPh7/djIziO5Pfnk72ZiTw8qjUIBiCzlT/hf8xjBe+aF 4KHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Z7rpR8BkehrhSQ5szTWY+qRfncmTTZsQRTIZSTmWwI8=; b=BQATdHQfNYqxsAB8Iv3j8rKAEBTTNQlCqZJ8LMpEPbnj9wRw79AMwPPY9o978xE9YT 23ZrO6bUeSw2pqLBHW//p0pnW9dvmwGjc8NkHAPuhSO5qptKzCAdBMGKeU6rf5nXI6Zh SKWjiMaQTbSNurFBua9e8VneRqgkW7qBxp1Ng2wz1SQ82H64CFZBQ8g+vaTRCzRIeX0U wPFaNEDjot45iFZc9qONo2FJsC4Nmkod2BOB609aYzitb3YXbGijHCr6AR4ZIhtTcgle PxOtNStaE5ibMnPNg63hu58VHCub43sB4oWPnbInrvOHowX0kP2P0AoKIhT6v5GpBxOp ByZg== X-Gm-Message-State: AHYfb5jj0axGRwnZX2SavNo7QuJUGcem+oCLUBwPqvAmVfVvriDqg3Uh URDh7ZLDan+JGwxIf1G7Yu43EVkipA== X-Received: by 10.46.69.136 with SMTP id s130mr481731lja.6.1502128952232; Mon, 07 Aug 2017 11:02:32 -0700 (PDT) In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.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" Xref: news.gmane.org gmane.emacs.bugs:135545 Archived-At: --001a114b123a9ad06f05562da6f4 Content-Type: text/plain; charset="UTF-8" On Mon, Aug 7, 2017 at 1:53 PM Noam Postavsky < npostavs@users.sourceforge.net> wrote: > > hmm, I can't reproduce here, but is it possible you have bound C-M-\ > to some other command which calls indent-region non-interactively? > Thanks for verifying. Of course it was my config.. This deviates from this bug report.. but I am open to suggestions on how I could retain the * property of the interactive form while setting the region boundaries as I do in the below advice. I confirm that your suggestion also works fine if I remove the below advice from my config. ===== (defvar modi/region-or-whole-fns '(indent-region eval-region) "List of functions to act on the whole buffer if no region is selected.") (defun modi/advice-region-or-whole (orig-fun &rest args) "Advice function that applies ORIG-FUN to the whole buffer if no region is selected. http://thread.gmane.org/gmane.emacs.help/109025/focus=109102 " ;; Required to override the "r" argument of `interactive' in functions like ;; `indent-region' so that they can be called without an active region. (interactive (if (use-region-p) (list (region-beginning) (region-end)) (list (point-min) (point-max)))) ;; (message "Args: %S R: %S I: %S" ;; args (use-region-p) (called-interactively-p 'interactive)) (prog1 ; Return value of the advising fn needs to be the same as ORIG-FUN (apply orig-fun args) (when (and (called-interactively-p 'interactive) (not (use-region-p))) (message "Executed %s on the whole buffer." (propertize (symbol-name this-command) 'face 'font-lock-function-name-face))))) (dolist (fn modi/region-or-whole-fns) (advice-add fn :around #'modi/advice-region-or-whole) ;; (advice-remove fn #'modi/advice-region-or-whole) ) ===== -- Kaushal Modi --001a114b123a9ad06f05562da6f4 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Mon, Aug 7,= 2017 at 1:53 PM Noam Postavsky <npostavs@users.sourceforge.net> wrote:

hmm, I can't reproduce here, but is it possible you have bound C-M-\ to some other command which calls indent-region non-interactively?

Thanks for verifying. Of course it was my confi= g..

This deviates from this bug report.. but I am = open to suggestions on how I could retain the * property of the interactive= form while setting the region boundaries as I do in the below advice.

I confirm that your suggestion also works fine if I re= move the below advice from my config.

=3D=3D=3D=3D= =3D
(defvar modi/region-or-whole-fns '(indent-region
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0eval-region)
= =C2=A0 "List of functions to act on the whole buffer if no region is s= elected.")

(defun modi/advice-region-or-whole= (orig-fun &rest args)
=C2=A0 "Advice function that appl= ies ORIG-FUN to the whole buffer if no region is
selected.
<= div>http://thread.gmane.org/gmane.emacs.help/109025/focus=3D109102 &quo= t;
=C2=A0 ;; Required to override the "r" argument of `= interactive' in functions like
=C2=A0 ;; `indent-region' = so that they can be called without an active region.
=C2=A0 (inte= ractive (if (use-region-p)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(list (region-beginning) (region-end))
=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(list (p= oint-min) (point-max))))
=C2=A0 ;; (message "Args: %S R: %S = I: %S"
=C2=A0 ;; =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0args (use= -region-p) (called-interactively-p 'interactive))
=C2=A0 (pro= g1 ; Return value of the advising fn needs to be the same as ORIG-FUN
=
=C2=A0 =C2=A0 =C2=A0 (apply orig-fun args)
=C2=A0 =C2=A0 (wh= en (and (called-interactively-p 'interactive)
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(not (use-region-p)))
= =C2=A0 =C2=A0 =C2=A0 (message "Executed %s on the whole buffer."<= /div>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(propertiz= e (symbol-name this-command)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0'face = 9;font-lock-function-name-face)))))

(dolist (fn mo= di/region-or-whole-fns)
=C2=A0 (advice-add fn :around #'modi/= advice-region-or-whole)
=C2=A0 ;; (advice-remove fn #'modi/ad= vice-region-or-whole)
=C2=A0 )=C2=A0
=3D=3D=3D=3D=3D
--

Kaushal Modi

--001a114b123a9ad06f05562da6f4--