* [PATCHES] Minor patches for Remember, Minibuffer and Tab Bar
@ 2020-12-05 4:26 Gabriel do Nascimento Ribeiro
2020-12-05 16:03 ` Drew Adams
2021-01-05 18:58 ` Juri Linkov
0 siblings, 2 replies; 11+ messages in thread
From: Gabriel do Nascimento Ribeiro @ 2020-12-05 4:26 UTC (permalink / raw)
To: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 248 bytes --]
Hi,
Here are some suggestions of minor patches. Hope it's useful in some
way.
This patch:
- adds a trailing space to minibuffer depth indicator, so it has some
distance from minibuffer prompt
- adds a new face 'minibuffer-depth-indicator'
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Add trailing space and new face to minnibufer depth --]
[-- Type: text/x-diff, Size: 1106 bytes --]
diff --git a/lisp/mb-depth.el b/lisp/mb-depth.el
index 7ee7525d9f..aa12911822 100644
--- a/lisp/mb-depth.el
+++ b/lisp/mb-depth.el
@@ -35,6 +35,9 @@ minibuffer-depth-indicator-function
It is called with one argument, the minibuffer depth,
and must return a string.")
+(defface minibuffer-depth-indicator '((t :inherit highlight))
+ "Face to use for minibuffer depth indicator.")
+
;; An overlay covering the prompt. This is a buffer-local variable in
;; each affected minibuffer.
;;
@@ -52,7 +55,10 @@ minibuffer-depth-setup
(overlay-put minibuffer-depth-overlay 'before-string
(if minibuffer-depth-indicator-function
(funcall minibuffer-depth-indicator-function depth)
- (propertize (format "[%d]" depth) 'face 'highlight)))
+ (concat (propertize (format "[%d]" depth)
+ 'face
+ 'minibuffer-depth-indicator)
+ " ")))
(overlay-put minibuffer-depth-overlay 'evaporate t))))
;;;###autoload
[-- Attachment #3: Type: text/plain, Size: 747 bytes --]
This patch:
- removes unused 'org-remember-handler' from
'remember-handler-functions'
- adds a new option 'remember-item-format-function' to be used with
'remember-append-to-file'. This allows the user to specifify a custom
function to format a remember item. The current format uses a
hardcoded format that consists of 'remember-leader-text' +
'remember-time-format' + short description for the header and the
'buffer-string' for the body
- adds a new option 'remember-diary-regexp' to extract the hardcoded
and undocumented regexp used on 'remember-diary-extract-entries'
- adds logic to automatically save the diary buffer on
'remember-diary-extract-entries' respecting the value of
'remember-save-after-remembering'
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: Add some custom options to Remember --]
[-- Type: text/x-diff, Size: 3347 bytes --]
diff --git a/lisp/textmodes/remember.el b/lisp/textmodes/remember.el
index 7bc7dc1762..bbe11967f0 100644
--- a/lisp/textmodes/remember.el
+++ b/lisp/textmodes/remember.el
@@ -221,8 +221,7 @@ remember-handler-functions
:options '(remember-store-in-mailbox
remember-append-to-file
remember-store-in-files
- remember-diary-extract-entries
- org-remember-handler)
+ remember-diary-extract-entries)
:group 'remember)
(defcustom remember-all-handler-functions nil
@@ -410,16 +409,28 @@ remember-time-format
:group 'remember
:version "27.1")
+(defcustom remember-item-format-function nil
+ "The function to format a remembered item.
+The function receives one argument, the remember text, and
+should return the text to be remembered.
+If nil, use default format.'"
+ :type 'function
+ :group 'remember
+ :version "28.1")
+
(defun remember-append-to-file ()
"Remember, with description DESC, the given TEXT."
(let* ((text (buffer-string))
+ (buf (find-buffer-visiting remember-data-file))
(desc (remember-buffer-desc))
- (remember-text (concat "\n" remember-leader-text
- (format-time-string remember-time-format)
- " (" desc ")\n\n" text
+ (remember-text (concat "\n"
+ (if remember-item-format-function
+ (funcall remember-item-format-function text)
+ (concat remember-leader-text
+ (format-time-string remember-time-format)
+ " (" desc ")\n\n" text))
(save-excursion (goto-char (point-max))
- (if (bolp) nil "\n"))))
- (buf (find-buffer-visiting remember-data-file)))
+ (if (bolp) nil "\n")))))
(if buf
(with-current-buffer buf
(save-excursion
@@ -502,6 +513,12 @@ remember-diary-file
:type '(choice (const :tag "diary-file" nil) file)
:group 'remember)
+(defcustom remember-diary-regexp "^DIARY:\\s-*\\(.+\\)"
+ "Regexp to extract diary entries."
+ :type '(regexp :tag "Diary entry")
+ :group 'remember
+ :version "28.1")
+
(defvar calendar-date-style) ; calendar.el
(defun remember-diary-convert-entry (entry)
@@ -534,15 +551,18 @@ remember-diary-convert-entry
;;;###autoload
(defun remember-diary-extract-entries ()
- "Extract diary entries from the region."
+ "Extract diary entries from the region based on `remember-diary-regexp'."
(save-excursion
(goto-char (point-min))
(let (list)
- (while (re-search-forward "^DIARY:\\s-*\\(.+\\)" nil t)
+ (while (re-search-forward remember-diary-regexp nil t)
(push (remember-diary-convert-entry (match-string 1)) list))
(when list
(diary-make-entry (mapconcat 'identity list "\n")
- nil remember-diary-file))
+ nil remember-diary-file t)
+ (when remember-save-after-remembering
+ (with-current-buffer (find-buffer-visiting diary-file)
+ (save-buffer))))
nil))) ;; Continue processing
;;; Internal Functions:
[-- Attachment #5: Type: text/plain, Size: 206 bytes --]
This patch:
- adds a new option 'tab-bar-history-buttons-show' to control
visibility of tab-bar-history back and forward buttons, similar to
'tab-bar-new-button-show' and 'tab-bar-close-button-show'
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #6: Adds options to hide tab-bar history buttons --]
[-- Type: text/x-diff, Size: 1142 bytes --]
diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index 2604955224..05611b48bb 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -296,6 +296,16 @@ tab-bar-back-button
(defvar tab-bar-forward-button " > "
"Button for going forward in tab history.")
+(defcustom tab-bar-history-buttons-show t
+ "Show back and forward buttons when `tab-bar-history-mode' is enabled."
+ :type 'boolean
+ :initialize 'custom-initialize-default
+ :set (lambda (sym val)
+ (set-default sym val)
+ (force-mode-line-update))
+ :group 'tab-bar
+ :version "28.1")
+
(defcustom tab-bar-tab-hints nil
"Show absolute numbers on tabs in the tab bar before the tab name.
This helps to select the tab by its number using `tab-bar-select-tab'
@@ -415,7 +425,7 @@ tab-bar-make-keymap-1
(tabs (funcall tab-bar-tabs-function)))
(append
'(keymap (mouse-1 . tab-bar-handle-mouse))
- (when tab-bar-history-mode
+ (when (and tab-bar-history-mode tab-bar-history-buttons-show)
`((sep-history-back menu-item ,separator ignore)
(history-back
menu-item ,tab-bar-back-button tab-bar-history-back
[-- Attachment #7: Type: text/plain, Size: 458 bytes --]
This patch:
- adds a new option 'tab-bar-tab-name-format-function' to let user
specify a custom function to format the final string of tab
name. This would be useful in many cases, for example, to add custom
properties/faces to final tab name or to trim spaces in case
'tab-bar-rename-tab' has trailing spaces. It could also fix a trailing
space when 'tab-bar-tab-hints' is set to true and
'tab-bar-tab-name-function' returns an empty string
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #8: Add option to format tab-bar tab name --]
[-- Type: text/x-diff, Size: 2247 bytes --]
diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index 2604955224..82f3ca2385 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -334,6 +334,18 @@ tab-bar-tab-name-function
:group 'tab-bar
:version "27.1")
+(defcustom tab-bar-tab-name-format-function nil
+ "Function to format a tab name.
+Function get one argument, the tab name, and should return
+the formatted tab name."
+ :type 'function
+ :initialize 'custom-initialize-default
+ :set (lambda (sym val)
+ (set-default sym val)
+ (force-mode-line-update))
+ :group 'tab-bar
+ :version "28.1")
+
(defun tab-bar-tab-name-current ()
"Generate tab name from the buffer of the selected window."
(buffer-name (window-buffer (minibuffer-selected-window))))
@@ -433,8 +445,9 @@ tab-bar-make-keymap-1
((eq (car tab) 'current-tab)
`((current-tab
menu-item
- ,(propertize (concat (if tab-bar-tab-hints (format "%d " i) "")
- (alist-get 'name tab)
+ ,(propertize (concat (funcall (or tab-bar-tab-name-format-function 'identity)
+ (concat (if tab-bar-tab-hints (format "%d " i) "")
+ (alist-get 'name tab)))
(or (and tab-bar-close-button-show
(not (eq tab-bar-close-button-show
'non-selected))
@@ -445,8 +458,9 @@ tab-bar-make-keymap-1
(t
`((,(intern (format "tab-%i" i))
menu-item
- ,(propertize (concat (if tab-bar-tab-hints (format "%d " i) "")
- (alist-get 'name tab)
+ ,(propertize (concat (funcall (or tab-bar-tab-name-format-function 'identity)
+ (concat (if tab-bar-tab-hints (format "%d " i) "")
+ (alist-get 'name tab)))
(or (and tab-bar-close-button-show
(not (eq tab-bar-close-button-show
'selected))
[-- Attachment #9: Type: text/plain, Size: 46 bytes --]
Regards,
Gabriel do Nascimento Ribeiro
^ permalink raw reply related [flat|nested] 11+ messages in thread
* RE: [PATCHES] Minor patches for Remember, Minibuffer and Tab Bar
2020-12-05 4:26 [PATCHES] Minor patches for Remember, Minibuffer and Tab Bar Gabriel do Nascimento Ribeiro
@ 2020-12-05 16:03 ` Drew Adams
2020-12-05 16:57 ` Gabriel do Nascimento Ribeiro
2020-12-05 20:30 ` Juri Linkov
2021-01-05 18:58 ` Juri Linkov
1 sibling, 2 replies; 11+ messages in thread
From: Drew Adams @ 2020-12-05 16:03 UTC (permalink / raw)
To: Gabriel do Nascimento Ribeiro, emacs-devel
> This patch:
> - adds a trailing space to minibuffer depth indicator, so
> it has some distance from minibuffer prompt
> - adds a new face 'minibuffer-depth-indicator'
Time travel...2006...
https://www.emacswiki.org/emacs/download/mb-depth%2b.el
And here's (all of) the code:
(defface minibuffer-depth-indicator '((t (:inherit default)))
"Face used to indicate minibuffer depth."
:group 'convenience :group 'faces)
(defcustom minibuffer-depth-indicator-format "%d) "
"Format string for minibuffer depth indicator."
:type 'string :group 'convenience)
;; REPLACE original defined in `mb-depth.el'.
;; Use face `minibuffer-depth-indicator' and option
;; `minibuffer-depth-indicator-format'.
;;
;; This function goes on `minibuffer-setup-hook'.
;;
(defun minibuffer-depth-setup ()
"Set up a minibuffer for `minibuffer-depth-indicate-mode'.
The prompt should already have been inserted."
(when (> (minibuffer-depth) 1)
(setq minibuffer-depth-overlay
(make-overlay (point-min) (1+ (point-min))))
(overlay-put minibuffer-depth-overlay 'before-string
(if minibuffer-depth-indicator-function
(funcall minibuffer-depth-indicator-function
(minibuffer-depth))
(propertize
(format minibuffer-depth-indicator-format
(minibuffer-depth))
'face 'minibuffer-depth-indicator)))
(overlay-put minibuffer-depth-overlay 'evaporate t)))
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCHES] Minor patches for Remember, Minibuffer and Tab Bar
2020-12-05 16:03 ` Drew Adams
@ 2020-12-05 16:57 ` Gabriel do Nascimento Ribeiro
2020-12-05 17:08 ` Drew Adams
2020-12-05 20:30 ` Juri Linkov
1 sibling, 1 reply; 11+ messages in thread
From: Gabriel do Nascimento Ribeiro @ 2020-12-05 16:57 UTC (permalink / raw)
To: emacs-devel
Drew Adams <drew.adams@oracle.com> writes:
>> This patch:
>> - adds a trailing space to minibuffer depth indicator, so
>> it has some distance from minibuffer prompt
>> - adds a new face 'minibuffer-depth-indicator'
>
> Time travel...2006...
>
> https://www.emacswiki.org/emacs/download/mb-depth%2b.el
Wow, 14 year ago...
I ask myself why we can't merge something like this to 'master'
branch. There are countless packages with the same purpose: to allow
customization of some hardcoded logic on Emacs that could be easily
turned into a set of user options without any downside (like affecting
compatibility or performance).
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCHES] Minor patches for Remember, Minibuffer and Tab Bar
2020-12-05 16:03 ` Drew Adams
2020-12-05 16:57 ` Gabriel do Nascimento Ribeiro
@ 2020-12-05 20:30 ` Juri Linkov
2020-12-05 21:52 ` Drew Adams
1 sibling, 1 reply; 11+ messages in thread
From: Juri Linkov @ 2020-12-05 20:30 UTC (permalink / raw)
To: Drew Adams; +Cc: Gabriel do Nascimento Ribeiro, emacs-devel
> (defcustom minibuffer-depth-indicator-format "%d) "
^
unbalanced parenthesis detected
^ permalink raw reply [flat|nested] 11+ messages in thread
* RE: [PATCHES] Minor patches for Remember, Minibuffer and Tab Bar
2020-12-05 20:30 ` Juri Linkov
@ 2020-12-05 21:52 ` Drew Adams
2020-12-05 21:58 ` Juri Linkov
0 siblings, 1 reply; 11+ messages in thread
From: Drew Adams @ 2020-12-05 21:52 UTC (permalink / raw)
To: Juri Linkov; +Cc: Gabriel do Nascimento Ribeiro, emacs-devel
> > (defcustom minibuffer-depth-indicator-format "%d) "
> ^
> unbalanced parenthesis detected
Not in my world. Detected by whom?
If some version of Emacs is flagging that then it's
a regression. There's no unbalanced paren. Here's
the full definition, again:
(defcustom minibuffer-depth-indicator-format "%d) "
"Format string for minibuffer depth indicator."
:type 'string :group 'convenience)
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCHES] Minor patches for Remember, Minibuffer and Tab Bar
2020-12-05 21:52 ` Drew Adams
@ 2020-12-05 21:58 ` Juri Linkov
2020-12-05 22:48 ` Drew Adams
0 siblings, 1 reply; 11+ messages in thread
From: Juri Linkov @ 2020-12-05 21:58 UTC (permalink / raw)
To: Drew Adams; +Cc: Gabriel do Nascimento Ribeiro, emacs-devel
>> > (defcustom minibuffer-depth-indicator-format "%d) "
>> ^
>> unbalanced parenthesis detected
>
> Not in my world. Detected by whom?
>
> If some version of Emacs is flagging that then it's
> a regression. There's no unbalanced paren. Here's
> the full definition, again:
>
> (defcustom minibuffer-depth-indicator-format "%d) "
> "Format string for minibuffer depth indicator."
> :type 'string :group 'convenience)
Wouldn't you feel that something is wrong every time seeing unbalanced
1) 2) 3)
in the prompt? I think the current default [%s] is better
than the default value that you propose. But I agree that
the format could be customizable.
^ permalink raw reply [flat|nested] 11+ messages in thread
* RE: [PATCHES] Minor patches for Remember, Minibuffer and Tab Bar
2020-12-05 21:58 ` Juri Linkov
@ 2020-12-05 22:48 ` Drew Adams
0 siblings, 0 replies; 11+ messages in thread
From: Drew Adams @ 2020-12-05 22:48 UTC (permalink / raw)
To: Juri Linkov; +Cc: Gabriel do Nascimento Ribeiro, emacs-devel
> Wouldn't you feel that something is wrong every time seeing unbalanced
> 1) 2) 3)
>
> in the prompt?
Uh, no, clearly I don't feel that something is wrong.
Otherwise, I wouldn't have used that as default value.
Why would anyone expect such a paren to be balanced
preceding a prompt? Where/how did you actually see the
error/warning message you posted about this?
But anyone can change the text used for this. That's
the point of having it as a user option.
> I think the current default [%s] is better than the
> default value that you propose.
OK. "Les goûts et les couleurs, ça ne se discute pas."
Is "the current" really a default? Or is it instead
hardcoded?
FWIW, I use recursive minibuffers often. A prompt
prefix of "N) " is fine, IMO.
> But I agree that the format could be customizable.
Good.
___
What's more, I also color the minibuffer background a
slightly different hue each time you enter a new level.
That's probably relevant only for a standalone minibuffer
frame. But it makes a tremendous difference, even though
the hue change is very slight.
I pretty much never look at the actual level number in
the prompt. Instead, I recognize the hue change, and
in particular the hues of the top and second levels -
I sense the level subconsciously.
___
FWIW, I'm all for making a recursive edit or a recursive
minibuffer more obvious. For the former, my tiny library
`rec-edit.el' highlights the recursive-edit brackets in
the mode line to make it more obvious when you're in a
recursive edit and what the level is.
https://www.emacswiki.org/emacs/RecursiveEdit#rec-edit.el
https://www.emacswiki.org/emacs/download/rec-edit.el
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCHES] Minor patches for Remember, Minibuffer and Tab Bar
2020-12-05 4:26 [PATCHES] Minor patches for Remember, Minibuffer and Tab Bar Gabriel do Nascimento Ribeiro
2020-12-05 16:03 ` Drew Adams
@ 2021-01-05 18:58 ` Juri Linkov
2021-01-05 23:52 ` Gabriel do Nascimento Ribeiro
1 sibling, 1 reply; 11+ messages in thread
From: Juri Linkov @ 2021-01-05 18:58 UTC (permalink / raw)
To: Gabriel do Nascimento Ribeiro; +Cc: emacs-devel
> Here are some suggestions of minor patches. Hope it's useful in some
> way.
>
> This patch:
> - adds a trailing space to minibuffer depth indicator, so it has some
> distance from minibuffer prompt
It hard-codes the space character, but it would be more user-friendly to
allow customization of its format string with a new user option with such
the default value: "[%d]".
> This patch:
> - adds a new option 'tab-bar-history-buttons-show' to control
> visibility of tab-bar-history back and forward buttons, similar to
> 'tab-bar-new-button-show' and 'tab-bar-close-button-show'
Thanks, now your patch is pushed to master.
> This patch:
> - adds a new option 'tab-bar-tab-name-format-function' to let user
> specify a custom function to format the final string of tab
> name. This would be useful in many cases, for example, to add custom
> properties/faces to final tab name or to trim spaces in case
> 'tab-bar-rename-tab' has trailing spaces. It could also fix a trailing
> space when 'tab-bar-tab-hints' is set to true and
> 'tab-bar-tab-name-function' returns an empty string
Now a more general option 'tab-bar-tab-name-format-function'
is pushed to master that allows easier customization for the
format of tab names.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCHES] Minor patches for Remember, Minibuffer and Tab Bar
2021-01-05 18:58 ` Juri Linkov
@ 2021-01-05 23:52 ` Gabriel do Nascimento Ribeiro
2021-01-06 18:28 ` Juri Linkov
0 siblings, 1 reply; 11+ messages in thread
From: Gabriel do Nascimento Ribeiro @ 2021-01-05 23:52 UTC (permalink / raw)
To: emacs-devel
Juri Linkov <juri@linkov.net> writes:
>> Here are some suggestions of minor patches. Hope it's useful in some
>> way.
>>
>> This patch:
>> - adds a trailing space to minibuffer depth indicator, so it has some
>> distance from minibuffer prompt
>
> It hard-codes the space character, but it would be more user-friendly to
> allow customization of its format string with a new user option with such
> the default value: "[%d]".
>
There is already 'minibuffer-depth-indicator-function' for this
customization, actually. My proposal was just to have a better default
value by adding a new face and by adding a single space between the
depth indicator and the minibuffer prompt.
>> This patch:
>> - adds a new option 'tab-bar-history-buttons-show' to control
>> visibility of tab-bar-history back and forward buttons, similar to
>> 'tab-bar-new-button-show' and 'tab-bar-close-button-show'
>
> Thanks, now your patch is pushed to master.
Thank you!
>
>> This patch:
>> - adds a new option 'tab-bar-tab-name-format-function' to let user
>> specify a custom function to format the final string of tab
>> name. This would be useful in many cases, for example, to add custom
>> properties/faces to final tab name or to trim spaces in case
>> 'tab-bar-rename-tab' has trailing spaces. It could also fix a trailing
>> space when 'tab-bar-tab-hints' is set to true and
>> 'tab-bar-tab-name-function' returns an empty string
>
> Now a more general option 'tab-bar-tab-name-format-function'
> is pushed to master that allows easier customization for the
> format of tab names.
Thank you!
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCHES] Minor patches for Remember, Minibuffer and Tab Bar
2021-01-05 23:52 ` Gabriel do Nascimento Ribeiro
@ 2021-01-06 18:28 ` Juri Linkov
0 siblings, 0 replies; 11+ messages in thread
From: Juri Linkov @ 2021-01-06 18:28 UTC (permalink / raw)
To: Gabriel do Nascimento Ribeiro; +Cc: emacs-devel
>>> This patch:
>>> - adds a trailing space to minibuffer depth indicator, so it has some
>>> distance from minibuffer prompt
>>
>> It hard-codes the space character, but it would be more user-friendly to
>> allow customization of its format string with a new user option with such
>> the default value: "[%d]".
>
> There is already 'minibuffer-depth-indicator-function' for this
> customization, actually. My proposal was just to have a better default
> value by adding a new face and by adding a single space between the
> depth indicator and the minibuffer prompt.
You are right, it's already easy to customize. So your patch is now
pushed to master. Thank you.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2021-01-06 18:28 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-05 4:26 [PATCHES] Minor patches for Remember, Minibuffer and Tab Bar Gabriel do Nascimento Ribeiro
2020-12-05 16:03 ` Drew Adams
2020-12-05 16:57 ` Gabriel do Nascimento Ribeiro
2020-12-05 17:08 ` Drew Adams
2020-12-05 20:30 ` Juri Linkov
2020-12-05 21:52 ` Drew Adams
2020-12-05 21:58 ` Juri Linkov
2020-12-05 22:48 ` Drew Adams
2021-01-05 18:58 ` Juri Linkov
2021-01-05 23:52 ` Gabriel do Nascimento Ribeiro
2021-01-06 18:28 ` Juri Linkov
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.