GNU bug report logs -
#22819
25.0.91; Don't try to indent region if the buffer is read-only
Previous Next
Reported by: Kaushal Modi <kaushal.modi <at> gmail.com>
Date: Fri, 26 Feb 2016 13:56:02 UTC
Severity: wishlist
Tags: patch, wontfix
Found in version 25.0.91
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
On Mon, Aug 7, 2017 at 1:53 PM Noam Postavsky <
npostavs <at> 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
[Message part 2 (text/html, inline)]
This bug report was last modified 5 years and 331 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.