all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Kaushal Modi <kaushal.modi@gmail.com>
To: Noam Postavsky <npostavs@users.sourceforge.net>
Cc: 22819@debbugs.gnu.org
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	[thread overview]
Message-ID: <CAFyQvY1yHiB7qO8KdZst9xVj9g0nMM64f0X2HNEUasMsnh7pWA@mail.gmail.com> (raw)
In-Reply-To: <CAM-tV--xg4Xm1UUwzpHYG8VejUkJXBtEGy+h7nTqfM_-cZOAYA@mail.gmail.com>

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

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

[-- Attachment #2: Type: text/html, Size: 2915 bytes --]

  reply	other threads:[~2017-08-07 18:02 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-26 13:54 bug#22819: 25.0.91; Don't try to indent region if the buffer is read-only Kaushal Modi
2017-08-05  1:56 ` npostavs
2017-08-05  6:52   ` Eli Zaretskii
2017-08-05 11:50     ` Kaushal Modi
2017-08-05 12:10       ` Eli Zaretskii
2017-08-05 12:29         ` Kaushal Modi
2017-08-05 12:37           ` Eli Zaretskii
2017-08-05 12:47         ` npostavs
2017-08-05 13:13           ` Eli Zaretskii
2017-08-07 17:45       ` Kaushal Modi
2017-08-07 17:53         ` Noam Postavsky
2017-08-07 18:02           ` Kaushal Modi [this message]
2017-08-07 18:11             ` Noam Postavsky
2017-08-08 13:06               ` Kaushal Modi
2017-08-08 13:15                 ` npostavs
2017-08-08 19:05                 ` Eli Zaretskii
2017-08-08 19:19                   ` Kaushal Modi
2017-08-08 21:31                     ` John Wiegley
2017-08-09 11:03                       ` Kaushal Modi
2017-08-09 21:14                         ` John Wiegley
2019-06-25 14:33                   ` Lars Ingebrigtsen
2019-06-25 14:35                     ` Kaushal Modi

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFyQvY1yHiB7qO8KdZst9xVj9g0nMM64f0X2HNEUasMsnh7pWA@mail.gmail.com \
    --to=kaushal.modi@gmail.com \
    --cc=22819@debbugs.gnu.org \
    --cc=npostavs@users.sourceforge.net \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.