emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/beframe 4ca2206b3c 08/19: Add user option beframe-renam


From: ELPA Syncer
Subject: [elpa] externals/beframe 4ca2206b3c 08/19: Add user option beframe-rename-function
Date: Thu, 23 Feb 2023 13:57:24 -0500 (EST)

branch: externals/beframe
commit 4ca2206b3cea35f9b31cb800916af9192c901dc4
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>

    Add user option beframe-rename-function
---
 README.org |  5 ++++-
 beframe.el | 29 +++++++++++++++++++++++------
 2 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/README.org b/README.org
index 275ce552c3..76144ba86e 100644
--- a/README.org
+++ b/README.org
@@ -93,8 +93,11 @@ The ~beframe-mode~ does the following:
 - Add a filter to newly created frames so that their
   ~buffer-predicate~ parameter beframes buffers.
 
+  #+vindex: beframe-rename-function
 - Renames newly created frames so that they have a potentially more
-  meaningful title.
+  meaningful title.  The user option ~beframe-rename-function~
+  specifies the function that handles this process.  When its value is
+  nil, no renaming is performed.
 
  #+vindex: beframe-functions-in-frames
 - When the user option ~beframe-functions-in-frames~ contains a list
diff --git a/beframe.el b/beframe.el
index 4ccc668f7d..8b0f08dc69 100644
--- a/beframe.el
+++ b/beframe.el
@@ -62,7 +62,9 @@
 ;;   `buffer-predicate' parameter beframes buffers.
 ;;
 ;; - Renames newly created frames so that they have a potentially more
-;;   meaningful title.
+;;   meaningful title.  The user option `beframe-rename-function'
+;;   specifies the function that handles this process.  When its value
+;;   is nil, no renaming is performed.
 ;;
 ;;  #+vindex: beframe-functions-in-frames
 ;; - When the user option `beframe-functions-in-frames' contains a list
@@ -126,6 +128,22 @@ function so that every invocation of it is called with
          (beframe--functions-in-frames))
   :type '(repeat symbol))
 
+(defcustom beframe-rename-function #'beframe-rename-frame
+  "Function that renames new frames when `beframe-mode' is enabled.
+
+The function accepts one argument, the current frame, as is
+called by the `after-make-frame-functions' hook.
+
+If nil, no renaming is performed."
+  :group 'beframe
+  :package-version '(beframe . "0.2.0")
+  :initialize #'custom-initialize-default
+  :set (lambda (symbol value)
+         (beframe--functions-in-frames :disable)
+         (set-default symbol value)
+         (beframe--functions-in-frames))
+  :type '(repeat symbol))
+
 (defun beframe--frame-buffers (&optional frame)
   "Produce list of buffers for either specified or current FRAME."
   (seq-filter
@@ -275,9 +293,8 @@ The window manager must permit such an operation.  See 
bug#61319:
 
 ;;; Minor mode setup
 
-(defun beframe--rename-frame (frame)
-  "Rename FRAME.
-Add this to `after-make-frame-functions'."
+(defun beframe-rename-frame (frame)
+  "Rename FRAME per `beframe-rename-function'."
   (select-frame frame)
   (set-frame-name
    (cond
@@ -329,12 +346,12 @@ With optional DISABLE remove the advice."
         (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-frame)
+        (add-hook 'after-make-frame-functions #'beframe-rename-function)
         (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-frame)
+    (remove-hook 'after-make-frame-functions #'beframe-rename-function)
     (beframe--functions-in-frames :disable)))
 
 ;;;; Integration with `consult'



reply via email to

[Prev in Thread] Current Thread [Next in Thread]