From: Gabriel do Nascimento Ribeiro <gabriel376@hotmail.com>
To: emacs-devel@gnu.org
Subject: [PATCHES] Minor patches for Remember, Minibuffer and Tab Bar
Date: Sat, 05 Dec 2020 01:26:25 -0300 [thread overview]
Message-ID: <CH2PR01MB587905EB8149C34AD85FEA578BF00@CH2PR01MB5879.prod.exchangelabs.com> (raw)
[-- 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
next reply other threads:[~2020-12-05 4:26 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-05 4:26 Gabriel do Nascimento Ribeiro [this message]
2020-12-05 16:03 ` [PATCHES] Minor patches for Remember, Minibuffer and Tab Bar 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CH2PR01MB587905EB8149C34AD85FEA578BF00@CH2PR01MB5879.prod.exchangelabs.com \
--to=gabriel376@hotmail.com \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.