unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#20785: user-error for mark-inactive
@ 2015-06-10 23:34 Juri Linkov
  2015-06-11  3:11 ` Stefan Monnier
  0 siblings, 1 reply; 5+ messages in thread
From: Juri Linkov @ 2015-06-10 23:34 UTC (permalink / raw)
  To: 20785

A single remaining case that is too annoying is when the debugger is
called due to a user error while accidentally typing `C-w' (kill-region)
when there is no active mark in the buffer:

Debugger entered--Lisp error: (mark-inactive)
  signal(mark-inactive nil)
  mark()
  byte-code("\300 `\301E\207" [mark region] 3)
  call-interactively(kill-region nil nil)
  command-execute(kill-region)

The following patch avoids this in both cases:

1. when mark-even-if-inactive is non-nil, displays the message:
   "user-error: The mark is not set now, so there is no region"

2. when mark-even-if-inactive is nil, displays the message:
   "mark: The mark is not active now"

diff --git a/lisp/simple.el b/lisp/simple.el
index 1eb0643..31810a4 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -4017,7 +4021,7 @@ (defun kill-region (beg end &optional region)
   ;; calling `kill-append'.
   (interactive (list (mark) (point) 'region))
   (unless (and beg end)
-    (error "The mark is not set now, so there is no region"))
+    (user-error "The mark is not set now, so there is no region"))
   (condition-case nil
       (let ((string (if region
                         (funcall region-extract-function 'delete)

diff --git a/lisp/bindings.el b/lisp/bindings.el
index b658914..3672812 100644
--- a/lisp/bindings.el
+++ b/lisp/bindings.el
@@ -633,7 +633,7 @@ (setq debug-ignored-errors
       ;; file-supersession should all be user-errors!
       `(beginning-of-line beginning-of-buffer end-of-line
 	end-of-buffer end-of-file buffer-read-only
-	file-supersession
+	file-supersession mark-inactive
         user-error ;; That's the main one!
         ))
 





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

* bug#20785: user-error for mark-inactive
  2015-06-10 23:34 bug#20785: user-error for mark-inactive Juri Linkov
@ 2015-06-11  3:11 ` Stefan Monnier
  2015-06-11 23:17   ` Juri Linkov
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2015-06-11  3:11 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 20785

> A single remaining case that is too annoying is when the debugger is
> called due to a user error while accidentally typing `C-w' (kill-region)
> when there is no active mark in the buffer:

Looks OK to me (maybe we could also just signal `mark-inactive' instead
of calling user-error, but either way is OK for me),


        Stefan





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

* bug#20785: user-error for mark-inactive
  2015-06-11  3:11 ` Stefan Monnier
@ 2015-06-11 23:17   ` Juri Linkov
  2015-06-12  5:40     ` Stefan Monnier
  0 siblings, 1 reply; 5+ messages in thread
From: Juri Linkov @ 2015-06-11 23:17 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 20785-done

>> A single remaining case that is too annoying is when the debugger is
>> called due to a user error while accidentally typing `C-w' (kill-region)
>> when there is no active mark in the buffer:
>
> Looks OK to me

Installed.

> (maybe we could also just signal `mark-inactive' instead
> of calling user-error, but either way is OK for me),

I see that `mark-inactive' and user-error in `kill-region'
have different messages:

`mark-inactive' signaled in the function `mark'
has the message only about the mark:

  "The mark is not active now"

whereas the user-error message in `kill-region'
is specific about the region:

  "The mark is not set now, so there is no region"

and I don't see how to merge these messages.





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

* bug#20785: user-error for mark-inactive
  2015-06-11 23:17   ` Juri Linkov
@ 2015-06-12  5:40     ` Stefan Monnier
  2015-06-22 22:46       ` Juri Linkov
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2015-06-12  5:40 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 20785-done

> `mark-inactive' signaled in the function `mark'
> has the message only about the mark:

>   "The mark is not active now"

> whereas the user-error message in `kill-region'
> is specific about the region:

>   "The mark is not set now, so there is no region"

I'm not sure how important is this difference (or even if it's intentional).


        Stefan





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

* bug#20785: user-error for mark-inactive
  2015-06-12  5:40     ` Stefan Monnier
@ 2015-06-22 22:46       ` Juri Linkov
  0 siblings, 0 replies; 5+ messages in thread
From: Juri Linkov @ 2015-06-22 22:46 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 20785

>> `mark-inactive' signaled in the function `mark'
>> has the message only about the mark:
>
>>   "The mark is not active now"
>
>> whereas the user-error message in `kill-region'
>> is specific about the region:
>
>>   "The mark is not set now, so there is no region"
>
> I'm not sure how important is this difference (or even if it's intentional).

I noticed another occurrence in ‘shell-command-on-region’, so maybe better
to leave the mention of the region in all region-related commands.





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

end of thread, other threads:[~2015-06-22 22:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-10 23:34 bug#20785: user-error for mark-inactive Juri Linkov
2015-06-11  3:11 ` Stefan Monnier
2015-06-11 23:17   ` Juri Linkov
2015-06-12  5:40     ` Stefan Monnier
2015-06-22 22:46       ` Juri Linkov

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).