* 26.1: calc-mode header line [PATCH]
@ 2020-08-31 18:44 Boruch Baum
2020-09-05 6:57 ` Eli Zaretskii
0 siblings, 1 reply; 9+ messages in thread
From: Boruch Baum @ 2020-08-31 18:44 UTC (permalink / raw)
To: Emacs-Devel List
[-- Attachment #1: Type: text/plain, Size: 1119 bytes --]
Back in version 21, emacs introduced a static 'header-line' that could
be inserted at the top of any buffer. Calc mode is one emacs package
that does not use it and could benefit from it, so the attached patch
offers that feature. The main benefit is that the 'calc trail' buffer
(what some greybeards from the mechanical age would remember as the
'tape reel') no longer has its title line scroll off the visible
window. The patch also includes:
1) Width-sensitive text for the header line, so that it is readable for
very narrow windows, and scales to very wide windows.
2) Display of the 'calc trail' buffer when invoking calc from a frame
that is split vertically (C-x 3, M-x split-window-right).
3) My version of emacs includes a unicode character at 'C-x 8 <return>
POCKET CALCULATOR', that I did not include in the header line as the
mode's icon, but that could be done.
The patch was diff'ed against the version of emacs that I have: the
latest-and-greatest that debian is distributing ... v26.1
--
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1 7286 0036 9E45 1595 8BC0
[-- Attachment #2: calc.patch --]
[-- Type: text/x-diff, Size: 3417 bytes --]
--- calc.el 2020-08-30 15:03:07.563840474 -0400
+++ calc-new.el 2020-08-30 19:29:03.136433976 -0400
@@ -1410,15 +1410,30 @@
(setq buffer-read-only t)
(make-local-variable 'overlay-arrow-position)
(make-local-variable 'overlay-arrow-string)
- (when (= (buffer-size) 0)
- (let ((buffer-read-only nil))
- (insert (propertize "Emacs Calculator Trail\n" 'face 'italic)))))
+ (when calc-show-banner
+ (setq header-line-format
+ (let* ((fract (/ (window-width) 3))
+ (factor (if (> fract 19) 22 10))
+ (size (/ (- fract factor) 2))
+ (fill (make-string size ?-))
+ (pre (replace-regexp-in-string ".$" " " fill))
+ (post (replace-regexp-in-string "^." " " fill)))
+ (concat pre (if (= factor 22) "Emacs Calculator Trail" "Calc Trail") post)))))
(defun calc-create-buffer ()
"Create and initialize a buffer for the Calculator."
(set-buffer (get-buffer-create "*Calculator*"))
(or (derived-mode-p 'calc-mode)
(calc-mode))
+ (when calc-show-banner
+ (setq header-line-format
+ (let* ((fract (/ (* (window-width) 2) 3))
+ (factor (if (> fract 22) 21 10))
+ (size (/ (- fract factor) 2))
+ (fill (make-string size ?-))
+ (pre (replace-regexp-in-string ".$" " " fill))
+ (post (replace-regexp-in-string "^." " " fill)))
+ (concat pre (if (= factor 21) "Emacs Calculator Mode" "Emacs Calc") post))))
(setq max-lisp-eval-depth (max max-lisp-eval-depth 1000))
(when calc-always-load-extensions
(require 'calc-ext))
@@ -1465,7 +1480,6 @@
(pop-to-buffer (current-buffer)))))))
(with-current-buffer (calc-trail-buffer)
(and calc-display-trail
- (= (window-width) (frame-width))
(calc-trail-display 1 t)))
(message "Welcome to the GNU Emacs Calculator! Press `?' or `h' for help, `q' to quit")
(run-hooks 'calc-start-hook)
@@ -2000,13 +2014,8 @@
(calc-any-evaltos nil))
(setq calc-any-selections nil)
(erase-buffer)
- (when calc-show-banner
- (insert (propertize "--- Emacs Calculator Mode ---\n"
- 'face 'italic)))
(while thing
(goto-char (point-min))
- (when calc-show-banner
- (forward-line 1))
(insert (math-format-stack-value (car thing)) "\n")
(setq thing (cdr thing)))
(calc-renumber-stack)
@@ -2091,7 +2100,6 @@
(eq (marker-buffer calc-trail-pointer) calc-trail-buffer))
(with-current-buffer calc-trail-buffer
(goto-char (point-min))
- (forward-line 1)
(setq calc-trail-pointer (point-marker))))
calc-trail-buffer)
@@ -2159,10 +2167,8 @@
(if (derived-mode-p 'calc-trail-mode)
(progn
(beginning-of-line)
- (if (bobp)
- (forward-line 1)
(if (eobp)
- (forward-line -1)))
+ (forward-line -1))
(if (or (bobp) (eobp))
(setq overlay-arrow-position nil) ; trail is empty
(set-marker calc-trail-pointer (point) (current-buffer))
@@ -2176,7 +2182,7 @@
(if win
(save-excursion
(forward-line (/ (window-height win) 2))
- (forward-line (- 1 (window-height win)))
+ (forward-line (- 2 (window-height win)))
(set-window-start win (point))
(set-window-point win (+ calc-trail-pointer 4))
(set-buffer calc-main-buffer)
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: 26.1: calc-mode header line [PATCH]
2020-08-31 18:44 26.1: calc-mode header line [PATCH] Boruch Baum
@ 2020-09-05 6:57 ` Eli Zaretskii
2020-09-06 2:35 ` Boruch Baum
0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2020-09-05 6:57 UTC (permalink / raw)
To: Boruch Baum; +Cc: emacs-devel
> Date: Mon, 31 Aug 2020 14:44:45 -0400
> From: Boruch Baum <boruch_baum@gmx.com>
>
> Back in version 21, emacs introduced a static 'header-line' that could
> be inserted at the top of any buffer. Calc mode is one emacs package
> that does not use it and could benefit from it, so the attached patch
> offers that feature. The main benefit is that the 'calc trail' buffer
> (what some greybeards from the mechanical age would remember as the
> 'tape reel') no longer has its title line scroll off the visible
> window. The patch also includes:
Thanks, but it sounds like the change is backward-incompatible: the
old code which sets up the heading line is completely deleted, and if
calc-show-banner is nil, there's no heading line at all.
Can we please make this change backward-compatible, i.e. have a way
for users to get the previous behavior by setting calc-show-banner to
the nil value? Or maybe make your changes conditioned by a new value
of calc-show-banner, different from nil and t? Or maybe it's better
to introduce a new option?
In any case, there should be a NEWS item about the new behavior.
Bonus points for updating the Calc manual with the description of this
optional behavior.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: 26.1: calc-mode header line [PATCH]
2020-09-05 6:57 ` Eli Zaretskii
@ 2020-09-06 2:35 ` Boruch Baum
2020-09-06 14:17 ` Eli Zaretskii
0 siblings, 1 reply; 9+ messages in thread
From: Boruch Baum @ 2020-09-06 2:35 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: emacs-devel
On 2020-09-05 09:57, Eli Zaretskii wrote:
> > Date: Mon, 31 Aug 2020 14:44:45 -0400
> > From: Boruch Baum <boruch_baum@gmx.com>
> >
> > Back in version 21, emacs introduced a static 'header-line' that could
> > be inserted at the top of any buffer. Calc mode is one emacs package
> > that does not use it and could benefit from it, so the attached patch
> > offers that feature. The main benefit is that the 'calc trail' buffer
> > (what some greybeards from the mechanical age would remember as the
> > 'tape reel') no longer has its title line scroll off the visible
> > window. The patch also includes:
>
> Thanks, but it sounds like the change is backward-incompatible: the
> old code which sets up the heading line is completely deleted, and if
> calc-show-banner is nil, there's no heading line at all.
>
> Can we please make this change backward-compatible, i.e. have a way
> for users to get the previous behavior by setting calc-show-banner to
> the nil value?
OK, if you're certain that the current/prior behavior isn't itself a
bug, in that the user asks calc-show-banner to be nil but gets a banner
anyway.
> Or maybe make your changes conditioned by a new value of
> calc-show-banner, different from nil and t? Or maybe it's better to
> introduce a new option?
No need to clutter up with more options for something this trivial. If
your judgment is that the current behavior isn't a bug, let me know and
I'll just adjust the calc-show-banner-nil case to keep the current/prior
behavior.
> In any case, there should be a NEWS item about the new behavior.
Slow news day? Diff against this URL?
https://git.savannah.gnu.org/cgit/emacs.git/plain/etc/NEWS
--
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1 7286 0036 9E45 1595 8BC0
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: 26.1: calc-mode header line [PATCH]
2020-09-06 2:35 ` Boruch Baum
@ 2020-09-06 14:17 ` Eli Zaretskii
2020-09-06 18:45 ` Boruch Baum
0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2020-09-06 14:17 UTC (permalink / raw)
To: Boruch Baum; +Cc: emacs-devel
> Date: Sat, 5 Sep 2020 22:35:16 -0400
> From: Boruch Baum <boruch_baum@gmx.com>
> Cc: emacs-devel@gnu.org
>
> > Can we please make this change backward-compatible, i.e. have a way
> > for users to get the previous behavior by setting calc-show-banner to
> > the nil value?
>
> OK, if you're certain that the current/prior behavior isn't itself a
> bug, in that the user asks calc-show-banner to be nil but gets a banner
> anyway.
Yes, please.
> > Or maybe make your changes conditioned by a new value of
> > calc-show-banner, different from nil and t? Or maybe it's better to
> > introduce a new option?
>
> No need to clutter up with more options for something this trivial. If
> your judgment is that the current behavior isn't a bug, let me know and
> I'll just adjust the calc-show-banner-nil case to keep the current/prior
> behavior.
I don't have an opinion on this matter, I mentioned the possibility of
a new option only as an idea worth considering.
> > In any case, there should be a NEWS item about the new behavior.
>
> Slow news day? Diff against this URL?
>
> https://git.savannah.gnu.org/cgit/emacs.git/plain/etc/NEWS
Yes, thanks.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: 26.1: calc-mode header line [PATCH]
2020-09-06 14:17 ` Eli Zaretskii
@ 2020-09-06 18:45 ` Boruch Baum
2020-09-07 15:00 ` Lars Ingebrigtsen
0 siblings, 1 reply; 9+ messages in thread
From: Boruch Baum @ 2020-09-06 18:45 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 155 bytes --]
New patches attached.
On 2020-09-06 17:17, Eli Zaretskii wrote:
> ...
--
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1 7286 0036 9E45 1595 8BC0
[-- Attachment #2: calc.patch --]
[-- Type: text/x-diff, Size: 3524 bytes --]
--- calc.el 2020-08-30 15:03:07.563840474 -0400
+++ calc-new.el 2020-09-06 14:42:10.768154045 -0400
@@ -1410,15 +1410,33 @@
(setq buffer-read-only t)
(make-local-variable 'overlay-arrow-position)
(make-local-variable 'overlay-arrow-string)
- (when (= (buffer-size) 0)
+ (if (and (not calc-show-banner)
+ (= (buffer-size) 0))
(let ((buffer-read-only nil))
- (insert (propertize "Emacs Calculator Trail\n" 'face 'italic)))))
+ (insert (propertize "Emacs Calculator Trail\n" 'face 'italic)))
+ (setq header-line-format
+ (let* ((fract (/ (window-width) 3))
+ (factor (if (> fract 19) 22 10))
+ (size (/ (- fract factor) 2))
+ (fill (make-string size ?-))
+ (pre (replace-regexp-in-string ".$" " " fill))
+ (post (replace-regexp-in-string "^." " " fill)))
+ (concat pre (if (= factor 22) "Emacs Calculator Trail" "Calc Trail") post)))))
(defun calc-create-buffer ()
"Create and initialize a buffer for the Calculator."
(set-buffer (get-buffer-create "*Calculator*"))
(or (derived-mode-p 'calc-mode)
(calc-mode))
+ (when calc-show-banner
+ (setq header-line-format
+ (let* ((fract (/ (* (window-width) 2) 3))
+ (factor (if (> fract 22) 21 10))
+ (size (/ (- fract factor) 2))
+ (fill (make-string size ?-))
+ (pre (replace-regexp-in-string ".$" " " fill))
+ (post (replace-regexp-in-string "^." " " fill)))
+ (concat pre (if (= factor 21) "Emacs Calculator Mode" "Emacs Calc") post))))
(setq max-lisp-eval-depth (max max-lisp-eval-depth 1000))
(when calc-always-load-extensions
(require 'calc-ext))
@@ -1465,7 +1483,6 @@
(pop-to-buffer (current-buffer)))))))
(with-current-buffer (calc-trail-buffer)
(and calc-display-trail
- (= (window-width) (frame-width))
(calc-trail-display 1 t)))
(message "Welcome to the GNU Emacs Calculator! Press `?' or `h' for help, `q' to quit")
(run-hooks 'calc-start-hook)
@@ -2000,13 +2017,8 @@
(calc-any-evaltos nil))
(setq calc-any-selections nil)
(erase-buffer)
- (when calc-show-banner
- (insert (propertize "--- Emacs Calculator Mode ---\n"
- 'face 'italic)))
(while thing
(goto-char (point-min))
- (when calc-show-banner
- (forward-line 1))
(insert (math-format-stack-value (car thing)) "\n")
(setq thing (cdr thing)))
(calc-renumber-stack)
@@ -2091,7 +2103,6 @@
(eq (marker-buffer calc-trail-pointer) calc-trail-buffer))
(with-current-buffer calc-trail-buffer
(goto-char (point-min))
- (forward-line 1)
(setq calc-trail-pointer (point-marker))))
calc-trail-buffer)
@@ -2159,10 +2170,8 @@
(if (derived-mode-p 'calc-trail-mode)
(progn
(beginning-of-line)
- (if (bobp)
- (forward-line 1)
(if (eobp)
- (forward-line -1)))
+ (forward-line -1))
(if (or (bobp) (eobp))
(setq overlay-arrow-position nil) ; trail is empty
(set-marker calc-trail-pointer (point) (current-buffer))
@@ -2176,7 +2185,7 @@
(if win
(save-excursion
(forward-line (/ (window-height win) 2))
- (forward-line (- 1 (window-height win)))
+ (forward-line (- 2 (window-height win)))
(set-window-start win (point))
(set-window-point win (+ calc-trail-pointer 4))
(set-buffer calc-main-buffer)
[-- Attachment #3: NEWS.patch --]
[-- Type: text/x-diff, Size: 626 bytes --]
--- NEWS 2020-09-05 22:28:48.607653342 -0400
+++ NEWS.new 2020-09-06 14:37:38.286349012 -0400
@@ -921,6 +921,14 @@
Likewise, point isn't moved to the end of the string before inserting
digits.
+---
+*** Buffer headings have been changed.
+The *Calc* and *Calc Trail* buffers now use 'header-line-format' to
+present a persistent buffer header line, and they are sized based upon
+the window width upon launch. The header-line for the *Calc Trail*
+buffer is no longer part of the buffer's text and no longer scrolls
+off the visible display, unless on sets 'calc-show-banner' to NIL.
+
** term-mode
---
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: 26.1: calc-mode header line [PATCH]
2020-09-06 18:45 ` Boruch Baum
@ 2020-09-07 15:00 ` Lars Ingebrigtsen
2020-09-07 18:01 ` Boruch Baum
0 siblings, 1 reply; 9+ messages in thread
From: Lars Ingebrigtsen @ 2020-09-07 15:00 UTC (permalink / raw)
To: Boruch Baum; +Cc: Eli Zaretskii, emacs-devel
Boruch Baum <boruch_baum@gmx.com> writes:
> +The *Calc* and *Calc Trail* buffers now use 'header-line-format' to
> +present a persistent buffer header line, and they are sized based upon
> +the window width upon launch. The header-line for the *Calc Trail*
> +buffer is no longer part of the buffer's text and no longer scrolls
> +off the visible display, unless on sets 'calc-show-banner' to NIL.
The patch doesn't apply to Emacs 28, so I've respun it (included below).
The result looks nice, but one comment:
+ (setq header-line-format
+ (let* ((fract (/ (* (window-width) 2) 3))
+ (factor (if (> fract 22) 21 10))
+ (size (/ (- fract factor) 2))
+ (fill (make-string size ?-))
+ (pre (replace-regexp-in-string ".$" " " fill))
+ (post (replace-regexp-in-string "^." " " fill)))
+ (concat pre
+ (if (= factor 21) "Emacs Calculator Mode" "Emacs Calc")
+ post))))
This is somewhat inscrutable, and is repeated twice (once for the calc
buffer and once for the trail buffer).
It just centres whatever the string like "--- this ---", so it seems
like it should land in a single function for reuse.
diff --git a/lisp/calc/calc.el b/lisp/calc/calc.el
index fb1287baaa..2688ca14a4 100644
--- a/lisp/calc/calc.el
+++ b/lisp/calc/calc.el
@@ -1396,15 +1396,37 @@ calc-trail-mode
(setq buffer-read-only t)
(make-local-variable 'overlay-arrow-position)
(make-local-variable 'overlay-arrow-string)
- (when (= (buffer-size) 0)
- (let ((inhibit-read-only t))
- (insert (propertize "Emacs Calculator Trail\n" 'face 'italic)))))
+ (if (and (not calc-show-banner)
+ (= (buffer-size) 0))
+ (let ((inhibit-read-only t))
+ (insert (propertize "Emacs Calculator Trail\n" 'face 'italic)))
+ (setq header-line-format
+ (let* ((fract (/ (window-width) 3))
+ (factor (if (> fract 19) 22 10))
+ (size (/ (- fract factor) 2))
+ (fill (make-string size ?-))
+ (pre (replace-regexp-in-string ".$" " " fill))
+ (post (replace-regexp-in-string "^." " " fill)))
+ (concat pre
+ (if (= factor 22) "Emacs Calculator Trail" "Calc Trail")
+ post)))))
(defun calc-create-buffer ()
"Create and initialize a buffer for the Calculator."
(set-buffer (get-buffer-create "*Calculator*"))
(or (derived-mode-p 'calc-mode)
(calc-mode))
+ (when calc-show-banner
+ (setq header-line-format
+ (let* ((fract (/ (* (window-width) 2) 3))
+ (factor (if (> fract 22) 21 10))
+ (size (/ (- fract factor) 2))
+ (fill (make-string size ?-))
+ (pre (replace-regexp-in-string ".$" " " fill))
+ (post (replace-regexp-in-string "^." " " fill)))
+ (concat pre
+ (if (= factor 21) "Emacs Calculator Mode" "Emacs Calc")
+ post))))
(setq max-lisp-eval-depth (max max-lisp-eval-depth 1000))
(when calc-always-load-extensions
(require 'calc-ext))
@@ -1451,7 +1473,6 @@ calc
(pop-to-buffer (current-buffer)))))))
(with-current-buffer (calc-trail-buffer)
(and calc-display-trail
- (= (window-width) (frame-width))
(calc-trail-display 1 t)))
(message "Welcome to the GNU Emacs Calculator! Press `?' or `h' for help, `q' to quit")
(run-hooks 'calc-start-hook)
@@ -1986,13 +2007,8 @@ calc-refresh
(calc-any-evaltos nil))
(setq calc-any-selections nil)
(erase-buffer)
- (when calc-show-banner
- (insert (propertize "--- Emacs Calculator Mode ---\n"
- 'face 'italic)))
(while thing
(goto-char (point-min))
- (when calc-show-banner
- (forward-line 1))
(insert (math-format-stack-value (car thing)) "\n")
(setq thing (cdr thing)))
(calc-renumber-stack)
@@ -2076,7 +2092,6 @@ calc-trail-buffer
(eq (marker-buffer calc-trail-pointer) calc-trail-buffer))
(with-current-buffer calc-trail-buffer
(goto-char (point-min))
- (forward-line 1)
(setq calc-trail-pointer (point-marker))))
calc-trail-buffer)
@@ -2144,10 +2159,8 @@ calc-trail-here
(if (derived-mode-p 'calc-trail-mode)
(progn
(beginning-of-line)
- (if (bobp)
- (forward-line 1)
(if (eobp)
- (forward-line -1)))
+ (forward-line -1))
(if (or (bobp) (eobp))
(setq overlay-arrow-position nil) ; trail is empty
(set-marker calc-trail-pointer (point) (current-buffer))
@@ -2161,7 +2174,7 @@ calc-trail-here
(if win
(save-excursion
(forward-line (/ (window-height win) 2))
- (forward-line (- 1 (window-height win)))
+ (forward-line (- 2 (window-height win)))
(set-window-start win (point))
(set-window-point win (+ calc-trail-pointer 4))
(set-buffer calc-main-buffer)
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: 26.1: calc-mode header line [PATCH]
2020-09-07 15:00 ` Lars Ingebrigtsen
@ 2020-09-07 18:01 ` Boruch Baum
2020-09-07 20:24 ` Lars Ingebrigtsen
0 siblings, 1 reply; 9+ messages in thread
From: Boruch Baum @ 2020-09-07 18:01 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: Eli Zaretskii, emacs-devel
First, congratulations on assuming your new responsibilities.
On 2020-09-07 17:00, Lars Ingebrigtsen wrote:
> The patch doesn't apply to Emacs 28, so I've respun it (included below).
Oops. I didn't think there would be a difference. I'm using emacs 26.1
in debian and I didn't download the v28 calc.el
> This is somewhat inscrutable, and is repeated twice (once for the calc
> buffer and once for the trail buffer).
>
> It just centres whatever the string like "--- this ---", so it seems
> like it should land in a single function for reuse.
Come to think of it, its likely different forms of that kind of routine
has got to already exist somewhere else in emacs, probably in several
different packages.
For this patch, the reason I didn't reuse the code was because it was
small and there were two (maybe more?) differences in the hard-coded
constants: 1) 1/3 *parent* window width for the trail buffer versus 2/3
*parent* window width for the calc buffer; 2) unique constants based
upon four different string lengths plus I think fudge factor.
Off-topic: I have several private extensions to dired that are ready for
the introduction into the wild. Is it better to post them to the devel
mailing list for possibly wider discussion / consideration / criticism /
publicity, or post them to the bug mailing list as a feature / patch for
possibly better tracking?
1) display change - quickly change the 'ls' switches for a dired buffer
from among entries in an alist. The changing can be incremental in
the list or prompt the user based upon a useful plain-text
description. Just additional code. No change to current code.
2) history navigation - have each chain of dired buffers track where
they've been and allow navigation backward and forward within that
history. This does make a one-line change to a single current dired
function. It adds several navigation functions, including a form of
visit parent directory that adds a prefix argument to go up n levels
in your current directory tree.
3) pass dired variables to a shell - for any emacs shell or terminal
emulator, launch it from dired, and pass the current directory,
current file at point, current tagged files ... for both the current
dired buffer and an optional one other visible dired buffer on the
same frame ($d1 $d2 $f1 $f2 $t1 $t2). For this, I still need to
polish how the list of tagged files are handled (quoting, bash/zsh
array variables versus POSIX/sh ).
4) Recover a 'borked' dired session, useful if you've somehow
accumulated n buffers / windows / frames and want to restore a basic
setup.
5) Fully exit dired. Just kills all dired buffers everywhere.
6) Maybe more. My init file is long and my memory is short.
--
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1 7286 0036 9E45 1595 8BC0
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: 26.1: calc-mode header line [PATCH]
2020-09-07 18:01 ` Boruch Baum
@ 2020-09-07 20:24 ` Lars Ingebrigtsen
2020-09-07 21:11 ` Boruch Baum
0 siblings, 1 reply; 9+ messages in thread
From: Lars Ingebrigtsen @ 2020-09-07 20:24 UTC (permalink / raw)
To: Boruch Baum; +Cc: Eli Zaretskii, emacs-devel
Boruch Baum <boruch_baum@gmx.com> writes:
> For this patch, the reason I didn't reuse the code was because it was
> small and there were two (maybe more?) differences in the hard-coded
> constants: 1) 1/3 *parent* window width for the trail buffer versus 2/3
> *parent* window width for the calc buffer; 2) unique constants based
> upon four different string lengths plus I think fudge factor.
But none of those are constants, really -- the function could take two
strings and a width as input, and use (length string1) etc. That would
also make the code less fragile if the strings are changed later.
> Off-topic: I have several private extensions to dired that are ready for
> the introduction into the wild. Is it better to post them to the devel
> mailing list for possibly wider discussion / consideration / criticism /
> publicity, or post them to the bug mailing list as a feature / patch for
> possibly better tracking?
The latter, I think. It's easy to lose sight of patches on emacs-devel.
> 1) display change - quickly change the 'ls' switches for a dired buffer
> from among entries in an alist. The changing can be incremental in
> the list or prompt the user based upon a useful plain-text
> description. Just additional code. No change to current code.
Hm... sounds nice, but what's the use case?
> 2) history navigation - have each chain of dired buffers track where
> they've been and allow navigation backward and forward within that
> history. This does make a one-line change to a single current dired
> function. It adds several navigation functions, including a form of
> visit parent directory that adds a prefix argument to go up n levels
> in your current directory tree.
Isn't `C-x C-f M-DEL' a few times easier to remember?
> 3) pass dired variables to a shell - for any emacs shell or terminal
> emulator, launch it from dired, and pass the current directory,
> current file at point, current tagged files ... for both the current
> dired buffer and an optional one other visible dired buffer on the
> same frame ($d1 $d2 $f1 $f2 $t1 $t2). For this, I still need to
> polish how the list of tagged files are handled (quoting, bash/zsh
> array variables versus POSIX/sh ).
Hm. What do you use that for?
> 4) Recover a 'borked' dired session, useful if you've somehow
> accumulated n buffers / windows / frames and want to restore a basic
> setup.
I'm not sure what a "dired session" is? I just have a bunch of dired
buffers open, but I don't consider that a "session"...
> 5) Fully exit dired. Just kills all dired buffers everywhere.
That sounds very specialised. But I've often wanted a command that
would kill all buffers that have names that match a regexp, for
instance.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: 26.1: calc-mode header line [PATCH]
2020-09-07 20:24 ` Lars Ingebrigtsen
@ 2020-09-07 21:11 ` Boruch Baum
0 siblings, 0 replies; 9+ messages in thread
From: Boruch Baum @ 2020-09-07 21:11 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: Eli Zaretskii, emacs-devel
On 2020-09-07 22:24, Lars Ingebrigtsen wrote:
> Boruch Baum <boruch_baum@gmx.com> writes:
>
> > Off-topic: I have several private extensions to dired that are ready for
...
> > 1) display change - quickly change the 'ls' switches for a dired buffer
> > from among entries in an alist. The changing can be incremental in
> > the list or prompt the user based upon a useful plain-text
> > description. Just additional code. No change to current code.
>
> Hm... sounds nice, but what's the use case?
There are as many as there are combinations of 'ls' switches. There just
isn't enough room on a screen to show everything and most of the time
one doesn't need or want that much information, so one 'display' may omit
user/group, another show them as uid/gid, another show SElinux security
context, another show (or not) permissions, another have a different
date/time format, etc.
> > 2) history navigation - have each chain of dired buffers track where
> > they've been and allow navigation backward and forward within that
> > history. This does make a one-line change to a single current dired
> > function. It adds several navigation functions, including a form of
> > visit parent directory that adds a prefix argument to go up n levels
> > in your current directory tree.
>
> Isn't `C-x C-f M-DEL' a few times easier to remember?
I have no idea what that keybinding is. With my extension, I use simple
keybindings similar to those of many file managers: C-<left> and
C-<right> for history navigation, C-<up> for parent. Additionally, I
bind '/' for some more general navigation.
>
> > 3) pass dired variables to a shell - for any emacs shell or terminal
> > emulator, launch it from dired, and pass the current directory,
> > current file at point, current tagged files ... for both the current
> > dired buffer and an optional one other visible dired buffer on the
> > same frame ($d1 $d2 $f1 $f2 $t1 $t2). For this, I still need to
> > polish how the list of tagged files are handled (quoting, bash/zsh
> > array variables versus POSIX/sh ).
>
> Hm. What do you use that for?
I used to use (still do sometimes) Midnight Commander, which passes a
form of those variables to its shell. They're very convenient for performing
command line operations on those files.
> > 4) Recover a 'borked' dired session, useful if you've somehow
> > accumulated n buffers / windows / frames and want to restore a basic
> > setup.
>
> I'm not sure what a "dired session" is? I just have a bunch of dired
> buffers open, but I don't consider that a "session"...
OK. So, I just called it a session, no big deal. My background is that I
use S-<f11> as a dired launcher: it creates a frame named 'dired', and
gives it two side-by-side dired buffers/windows. From that frame, the
same keybinding toggles bag to my editor or whatever other frame. So it
seems like a session to me.
>
> > 5) Fully exit dired. Just kills all dired buffers everywhere.
>
> That sounds very specialised. But I've often wanted a command that
> would kill all buffers that have names that match a regexp, for
> instance.
If you want it, you'll see it was simple to code. IIRC, just walk the
buffer list and kill based upon your compare criteria. It could be
generalized, but I've only ever found a need for it for dired.
6) (or is it seven?) I just remembered: Another extension that's mature
and ready for the wild is dired quick preview feature almost identical
in operation to what exists in Midnight Commander with its 'C-x q'. As
you move point in dired in a file's line, it automatically opens a
buffer in the next window (emacs read-only "view-mode") after killing
any other preview buffer opened previously. It's a very quick way to
scan a files first page of contents, and you can use <tab> to quickly
navigate to/from the preview buffer to browse further. I use that a lot;
surprised I forgot to mention it in my original screed.
--
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1 7286 0036 9E45 1595 8BC0
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2020-09-07 21:11 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-31 18:44 26.1: calc-mode header line [PATCH] Boruch Baum
2020-09-05 6:57 ` Eli Zaretskii
2020-09-06 2:35 ` Boruch Baum
2020-09-06 14:17 ` Eli Zaretskii
2020-09-06 18:45 ` Boruch Baum
2020-09-07 15:00 ` Lars Ingebrigtsen
2020-09-07 18:01 ` Boruch Baum
2020-09-07 20:24 ` Lars Ingebrigtsen
2020-09-07 21:11 ` Boruch Baum
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).