unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#70230: 30.0.50; [PATCH] * lisp/master.el (master-says): check nil parameter
@ 2024-04-06  0:05 Lin Sun
  2024-04-06  8:06 ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Lin Sun @ 2024-04-06  0:05 UTC (permalink / raw)
  To: 70230

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

Hi,

The `(master-says)' will trigger an unexpected error message with follow code:

(require 'master)
(master-says)

> Wrong type argument: stringp, nil

The patch tries checking the nil parameter before calling `get-buffer'
to avoid the unexpected err message.

Please help check it. Thanks.

Best regards
Lin

[-- Attachment #2: 0001-lisp-master.el-master-says-check-nil-parameter.patch --]
[-- Type: text/x-patch, Size: 890 bytes --]

From 7a0dcde5fec2b7b7fdd1c74db1440183c11cfca6 Mon Sep 17 00:00:00 2001
From: Lin Sun <sunlin7@hotmail.com>
Date: Fri, 5 Apr 2024 06:58:07 +0000
Subject: [PATCH] * lisp/master.el (master-says): check nil parameter

---
 lisp/master.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/master.el b/lisp/master.el
index 0caf4d7963..4bdf686111 100644
--- a/lisp/master.el
+++ b/lisp/master.el
@@ -136,7 +136,8 @@ master-says-recenter
 (defun master-says (&optional command arg)
   "Display slave buffer and execute COMMAND with ARG in its window."
   (interactive)
-  (if (null (buffer-live-p (get-buffer master-of)))
+  (if (not (and master-of
+                (buffer-live-p (get-buffer master-of))))
       (error "Slave buffer has disappeared")
     (let ((window  (selected-window)))
       (if (not (eq (window-buffer window) (get-buffer master-of)))
-- 
2.20.5


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

* bug#70230: 30.0.50; [PATCH] * lisp/master.el (master-says): check nil parameter
  2024-04-06  0:05 bug#70230: 30.0.50; [PATCH] * lisp/master.el (master-says): check nil parameter Lin Sun
@ 2024-04-06  8:06 ` Eli Zaretskii
  2024-04-06 15:25   ` Lin Sun
  0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2024-04-06  8:06 UTC (permalink / raw)
  To: Lin Sun; +Cc: 70230

> From: Lin Sun <sunlin7.mail@gmail.com>
> Date: Sat, 6 Apr 2024 00:05:29 +0000
> 
> The `(master-says)' will trigger an unexpected error message with follow code:
> 
> (require 'master)
> (master-says)
> 
> > Wrong type argument: stringp, nil
> 
> The patch tries checking the nil parameter before calling `get-buffer'
> to avoid the unexpected err message.

Thanks, but "Slave buffer has disappeared" doesn't sound like a good
error message when master-of is nil, does it?





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

* bug#70230: 30.0.50; [PATCH] * lisp/master.el (master-says): check nil parameter
  2024-04-06  8:06 ` Eli Zaretskii
@ 2024-04-06 15:25   ` Lin Sun
  2024-04-06 15:30     ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Lin Sun @ 2024-04-06 15:25 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 70230

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

Hi Eli,

On Sat, Apr 6, 2024 at 8:06 AM Eli Zaretskii <eliz@gnu.org> wrote:
> Thanks, but "Slave buffer has disappeared" doesn't sound like a good
> error message when master-of is nil, does it?
Totally, the message will confuse the user. I modified the patch and
it checks the parameter `master-of' and gives a message "Slave buffer
does not exist" when it's nil.

Please help review again. Thanks.

[-- Attachment #2: 0001-lisp-master.el-master-says-check-nil-parameter.patch --]
[-- Type: application/x-patch, Size: 786 bytes --]

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

* bug#70230: 30.0.50; [PATCH] * lisp/master.el (master-says): check nil parameter
  2024-04-06 15:25   ` Lin Sun
@ 2024-04-06 15:30     ` Eli Zaretskii
  2024-04-06 21:26       ` Lin Sun
  0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2024-04-06 15:30 UTC (permalink / raw)
  To: Lin Sun; +Cc: 70230

> From: Lin Sun <sunlin7.mail@gmail.com>
> Date: Sat, 6 Apr 2024 15:25:35 +0000
> Cc: 70230@debbugs.gnu.org
> 
> On Sat, Apr 6, 2024 at 8:06 AM Eli Zaretskii <eliz@gnu.org> wrote:
> > Thanks, but "Slave buffer has disappeared" doesn't sound like a good
> > error message when master-of is nil, does it?
> Totally, the message will confuse the user. I modified the patch and
> it checks the parameter `master-of' and gives a message "Slave buffer
> does not exist" when it's nil.

I think "Slave buffer does not exist" is not the best message, since
the slave master is simply undefined in that case.  A better message
would be something like "Current buffer is not a master of any other
buffer".





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

* bug#70230: 30.0.50; [PATCH] * lisp/master.el (master-says): check nil parameter
  2024-04-06 15:30     ` Eli Zaretskii
@ 2024-04-06 21:26       ` Lin Sun
  2024-04-07  6:17         ` Eli Zaretskii
  0 siblings, 1 reply; 7+ messages in thread
From: Lin Sun @ 2024-04-06 21:26 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 70230

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

Hi Eli,

Yes, the "Current buffer is not a master of any other buffer" is more accurate.
The changed message path is attached.

Thank you so much!

[-- Attachment #2: 0001-lisp-master.el-master-says-check-nil-parameter.patch --]
[-- Type: text/x-patch, Size: 809 bytes --]

From 77a2e56374a7891bdd572f2ffa51f700c6fb809f Mon Sep 17 00:00:00 2001
From: Lin Sun <sunlin7@hotmail.com>
Date: Fri, 5 Apr 2024 06:58:07 +0000
Subject: [PATCH] * lisp/master.el (master-says): check nil parameter

---
 lisp/master.el | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lisp/master.el b/lisp/master.el
index 0caf4d7963..9151ca212d 100644
--- a/lisp/master.el
+++ b/lisp/master.el
@@ -136,6 +136,8 @@ master-says-recenter
 (defun master-says (&optional command arg)
   "Display slave buffer and execute COMMAND with ARG in its window."
   (interactive)
+  (unless master-of
+    (error "Current buffer is not a master of any other buffer"))
   (if (null (buffer-live-p (get-buffer master-of)))
       (error "Slave buffer has disappeared")
     (let ((window  (selected-window)))
-- 
2.20.5


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

* bug#70230: 30.0.50; [PATCH] * lisp/master.el (master-says): check nil parameter
  2024-04-06 21:26       ` Lin Sun
@ 2024-04-07  6:17         ` Eli Zaretskii
  2024-04-07 14:03           ` Lin Sun
  0 siblings, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2024-04-07  6:17 UTC (permalink / raw)
  To: Lin Sun; +Cc: 70230-done

> From: Lin Sun <sunlin7.mail@gmail.com>
> Date: Sat, 6 Apr 2024 21:26:49 +0000
> Cc: 70230@debbugs.gnu.org
> 
> Yes, the "Current buffer is not a master of any other buffer" is more accurate.
> The changed message path is attached.

Thanks, installed on master, and closing the bug.

P.S. Please in the future format the commit log message according to
our conventions, and also mention the bug number when known.





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

* bug#70230: 30.0.50; [PATCH] * lisp/master.el (master-says): check nil parameter
  2024-04-07  6:17         ` Eli Zaretskii
@ 2024-04-07 14:03           ` Lin Sun
  0 siblings, 0 replies; 7+ messages in thread
From: Lin Sun @ 2024-04-07 14:03 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 70230-done

Yes, will do that. Thank you!





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

end of thread, other threads:[~2024-04-07 14:03 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-06  0:05 bug#70230: 30.0.50; [PATCH] * lisp/master.el (master-says): check nil parameter Lin Sun
2024-04-06  8:06 ` Eli Zaretskii
2024-04-06 15:25   ` Lin Sun
2024-04-06 15:30     ` Eli Zaretskii
2024-04-06 21:26       ` Lin Sun
2024-04-07  6:17         ` Eli Zaretskii
2024-04-07 14:03           ` Lin Sun

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).