~protesilaos/general-issues

1

Beframe: beframe-rename-function cannot be set to nil

Karthik Chikmagalur <contact@karthinks.com>
Details
Message ID
<87a5w8yi1n.fsf@gmail.com>
DKIM signature
missing
Download raw message
Hi Prot,

The documentation for `beframe-rename-function' states:

"If nil, no renaming is performed."

But setting it to `nil' causes an error when creating new frames as
`nil' is added to `after-make-frame-functions' when turning on
`beframe-mode'.  To retain my frame naming scheme, I had to set it to
`#'ignore' instead.  The mode definition should either check for nil, or
the documentation should specify that it should be set to `ignore' to
disable renaming.

It's possible that `setopt' or `customize-set-variable' does the right
thing here and I missed it, since I used `setq'.  My apologies if this is
the case.

Karthik
Details
Message ID
<87sfa0bbav.fsf@protesilaos.com>
In-Reply-To
<87a5w8yi1n.fsf@gmail.com> (view parent)
DKIM signature
missing
Download raw message
Patch: +9 -2
> From: Karthik Chikmagalur <contact@karthinks.com>
> Date: Thu,  6 Jul 2023 12:08:20 -0700
>
> Hi Prot,

Hello Karthik,

> The documentation for `beframe-rename-function' states:
>
> "If nil, no renaming is performed."
>
> But setting it to `nil' causes an error when creating new frames as
> `nil' is added to `after-make-frame-functions' when turning on
> `beframe-mode'.  To retain my frame naming scheme, I had to set it to
> `#'ignore' instead.  The mode definition should either check for nil, or
> the documentation should specify that it should be set to `ignore' to
> disable renaming.

Oh, right!  Does this work for you?  Does it make sense?

 beframe.el | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/beframe.el b/beframe.el
index 8ec90fb..e9dc35a 100644
--- a/beframe.el
@@ -552,13 +552,13 @@ (define-minor-mode beframe-mode
        (setq beframe--read-buffer-function read-buffer-function
              read-buffer-function #'beframe-read-buffer)
        (add-hook 'after-make-frame-functions #'beframe--frame-predicate)
        (add-hook 'after-make-frame-functions beframe-rename-function)
        (add-hook 'after-make-frame-functions #'beframe-maybe-rename-frame)
        (add-hook 'after-make-frame-functions #'beframe-create-scratch-buffer)
        (beframe--functions-in-frames))
    (setq read-buffer-function beframe--read-buffer-function
          beframe--read-buffer-function nil)
    (remove-hook 'after-make-frame-functions #'beframe--frame-predicate)
    (remove-hook 'after-make-frame-functions beframe-rename-function)
    (remove-hook 'after-make-frame-functions #'beframe-maybe-rename-frame)
    (remove-hook 'after-make-frame-functions #'beframe-create-scratch-buffer)
    (beframe--functions-in-frames :disable)))

@@ -650,6 +650,13 @@ (defun beframe-rename-frame (frame &optional name)
   frame
   (list (cons 'name (beframe--infer-frame-name frame name)))))

(defun beframe-maybe-rename-frame (frame &optional name)
  "Helper function to determine if `beframe-rename-function' is called.
FRAME and optional NAME arguments are passed to the
`beframe-rename-function'."
  (when beframe-rename-function
    (funcall beframe-rename-function frame name)))

(defun beframe--frame-buffer-p (buf &optional frame)
  "Return non-nil if BUF belongs to the current frame.
Use optional FRAME to test if BUF belongs to it."


> It's possible that `setopt' or `customize-set-variable' does the right
> thing here and I missed it, since I used `setq'.  My apologies if this is
> the case.

I think it works in that case, though I also use 'setq' all the time.

All the best,
Prot

-- 
Protesilaos Stavrou
https://protesilaos.com
Reply to thread Export thread (mbox)