all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Help setting nadvice for indent-region
@ 2016-02-05 23:49 Kaushal Modi
  2016-02-05 23:58 ` Kaushal Modi
  2016-02-06 10:43 ` Michael Heerdegen
  0 siblings, 2 replies; 31+ messages in thread
From: Kaushal Modi @ 2016-02-05 23:49 UTC (permalink / raw
  To: Help Gnu Emacs mailing list

Hi,

I'd like to advice indent-region so that if a region is not select, it
indents between (point-min) and (point-max).

So I have this:

=====

(defun adv/indent-region (args)
  (when (not mark-active)
    (setq args (list (point-min) (point-max))))
  args)
(advice-add 'indent-region :filter-args #'adv/indent-region)

=====

This usually works, unless I have just launched a fresh buffer in which
there is no mark set.

If I do M-: (mark) in that buffer, I get nil.
In that case, if I call M-x indent-region (with no region selected), I get
this error backtrace:

Debugger entered--Lisp error: (error "The mark is not set now, so there is
no region")
  call-interactively(indent-region nil nil)
  command-execute(indent-region)

If it looks like the error is triggered by call-interactively even before
the advice gets to do its thing.

How can I resolve this using nadvice?

Thanks.

Kaushal Modi


^ permalink raw reply	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2016-02-12 19:04 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-05 23:49 Help setting nadvice for indent-region Kaushal Modi
2016-02-05 23:58 ` Kaushal Modi
2016-02-06  0:00   ` Kaushal Modi
2016-02-06  0:30   ` Emanuel Berg
2016-02-06  3:31     ` Kaushal Modi
2016-02-06 10:43 ` Michael Heerdegen
2016-02-07  3:12   ` Kaushal Modi
2016-02-07 17:46     ` Kaushal Modi
2016-02-07 18:51       ` John Mastro
2016-02-08  0:03         ` Emanuel Berg
2016-02-08  4:22           ` Kaushal Modi
2016-02-08 17:05             ` Eli Zaretskii
2016-02-08 17:27               ` Kaushal Modi
2016-02-09  3:07             ` Emanuel Berg
2016-02-08 20:03           ` John Mastro
2016-02-08 23:13             ` Emanuel Berg
2016-02-11 14:02         ` Stefan Monnier
2016-02-11 17:36           ` Kaushal Modi
2016-02-11 18:10             ` Michael Heerdegen
2016-02-11 18:47               ` Kaushal Modi
2016-02-11 18:56                 ` Kaushal Modi
2016-02-11 19:14                   ` Michael Heerdegen
2016-02-11 20:15                     ` Kaushal Modi
2016-02-11 20:38                       ` Kaushal Modi
2016-02-12 14:09                         ` Michael Heerdegen
2016-02-12 14:21                           ` Michael Heerdegen
2016-02-12 16:02                             ` Kaushal Modi
2016-02-12 19:04                               ` Michael Heerdegen
2016-02-12 13:57                       ` Michael Heerdegen
2016-02-11 19:03                 ` Michael Heerdegen
2016-02-07 23:48       ` Emanuel Berg

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.