emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] org-src: Improve the name of source editing buffers
@ 2023-03-02 14:02 Rudolf Adamkovič
  2023-03-05 21:26 ` Rudolf Adamkovič
  0 siblings, 1 reply; 9+ messages in thread
From: Rudolf Adamkovič @ 2023-03-02 14:02 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: Rudolf Adamkovič

* lisp/org-src.el (org-src--construct-edit-buffer-name): Fix the name
given to a source editing buffer.  The original format was documented
as "ORG-BUFFER-NAME [ LANG ]" but in reality it was 'ORG-BUFFER-NAME[
LANG ]', with different spacing.  We make the format more standard and
more compact, as well as, make the documentation match reality.
---
 lisp/org-src.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/org-src.el b/lisp/org-src.el
index 9e4392811..bb894de9c 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -315,8 +315,8 @@ is 0.")
 
 (defun org-src--construct-edit-buffer-name (org-buffer-name lang)
   "Construct the buffer name for a source editing buffer.
-Format is \"*Org Src ORG-BUFFER-NAME [ LANG ]*\"."
-  (concat "*Org Src " org-buffer-name "[ " lang " ]*"))
+Format is \"*Org Src ORG-BUFFER-NAME [LANG]*\"."
+  (concat "*Org Src " org-buffer-name " [" lang "]*"))
 
 (defun org-src--edit-buffer (beg end)
   "Return buffer editing area between BEG and END.
-- 
2.39.2



^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH] org-src: Improve the name of source editing buffers
  2023-03-02 14:02 [PATCH] org-src: Improve the name of source editing buffers Rudolf Adamkovič
@ 2023-03-05 21:26 ` Rudolf Adamkovič
  2023-03-06 12:09   ` Max Nikulin
  2023-03-07 13:13   ` Ihor Radchenko
  0 siblings, 2 replies; 9+ messages in thread
From: Rudolf Adamkovič @ 2023-03-05 21:26 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 226 bytes --]

I had a little bit of spare time today to refine the patch.

Changes:

- The patch now comes with a test to avoid regressions.
- The patch has a slightly better commit message.

Please see the attached file.

Thank you!

Rudy

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-src-Improve-naming-of-source-editing-buffers.patch --]
[-- Type: text/x-patch, Size: 2176 bytes --]

From a831b9014b3aaef16846dca049882a485ebf1dd6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rudolf=20Adamkovi=C4=8D?= <salutis@me.com>
Date: Sun, 5 Mar 2023 22:21:40 +0100
Subject: [PATCH] org-src: Improve naming of source editing buffers

* lisp/org-src.el (org-src--construct-edit-buffer-name): Fix the name
given to a source editing buffer.  The original format was documented
as "ORG-BUFFER-NAME [ LANG ]" but in reality it was "ORG-BUFFER-NAME[
LANG ]", with different spacing.  We make the format more standard and
more compact, as well as, make the documentation match reality.
* testing/lisp/test-org-src.el (test-org-src/buffer-name): Test the
buffer name used for 'org-edit-special'.
---
 lisp/org-src.el              |  4 ++--
 testing/lisp/test-org-src.el | 13 +++++++++++++
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/lisp/org-src.el b/lisp/org-src.el
index 9e4392811..bb894de9c 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -315,8 +315,8 @@ is 0.")
 
 (defun org-src--construct-edit-buffer-name (org-buffer-name lang)
   "Construct the buffer name for a source editing buffer.
-Format is \"*Org Src ORG-BUFFER-NAME [ LANG ]*\"."
-  (concat "*Org Src " org-buffer-name "[ " lang " ]*"))
+Format is \"*Org Src ORG-BUFFER-NAME [LANG]*\"."
+  (concat "*Org Src " org-buffer-name " [" lang "]*"))
 
 (defun org-src--edit-buffer (beg end)
   "Return buffer editing area between BEG and END.
diff --git a/testing/lisp/test-org-src.el b/testing/lisp/test-org-src.el
index 2a45ba66e..8829ce306 100644
--- a/testing/lisp/test-org-src.el
+++ b/testing/lisp/test-org-src.el
@@ -491,6 +491,19 @@ This is a tab:\t.
   (should (equal "#" (org-unescape-code-in-string "#")))
   (should (equal "," (org-unescape-code-in-string ","))))
 
+;;; Other
+
+(ert-deftest test-org-src/buffer-name ()
+  "Buffer has the correct name."
+  (org-test-with-temp-text "
+<point>#+begin_src emacs-lisp
+  (message hello)
+#+end_src"
+    (rename-buffer "Buffy")
+    (org-edit-special)
+    (should (equal "*Org Src Buffy [emacs-lisp]*"
+                   (buffer-name)))
+    (org-edit-src-exit)))
 
 (provide 'test-org-src)
 ;;; test-org-src.el ends here
-- 
2.39.2


[-- Attachment #3: Type: text/plain, Size: 208 bytes --]

-- 
"Be especially critical of any statement following the word
'obviously.'"
-- Anna Pell Wheeler, 1883-1966

Rudolf Adamkovič <salutis@me.com> [he/him]
Studenohorská 25
84103 Bratislava
Slovakia

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH] org-src: Improve the name of source editing buffers
  2023-03-05 21:26 ` Rudolf Adamkovič
@ 2023-03-06 12:09   ` Max Nikulin
  2023-03-07 13:13   ` Ihor Radchenko
  1 sibling, 0 replies; 9+ messages in thread
From: Max Nikulin @ 2023-03-06 12:09 UTC (permalink / raw)
  To: emacs-orgmode

On 06/03/2023 04:26, Rudolf Adamkovič wrote:
> -Format is \"*Org Src ORG-BUFFER-NAME [ LANG ]*\"."
> -  (concat "*Org Src " org-buffer-name "[ " lang " ]*"))
> +Format is \"*Org Src ORG-BUFFER-NAME [LANG]*\"."
> +  (concat "*Org Src " org-buffer-name " [" lang "]*"))

May it be a breaking change for users having customized 
`display-buffer-alist'? Should it be advertised in ORG-NEWS? I am not 
sure though.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] org-src: Improve the name of source editing buffers
  2023-03-05 21:26 ` Rudolf Adamkovič
  2023-03-06 12:09   ` Max Nikulin
@ 2023-03-07 13:13   ` Ihor Radchenko
  2023-03-07 21:15     ` Rudolf Adamkovič
  1 sibling, 1 reply; 9+ messages in thread
From: Ihor Radchenko @ 2023-03-07 13:13 UTC (permalink / raw)
  To: Rudolf Adamkovič; +Cc: emacs-orgmode

Rudolf Adamkovič <salutis@me.com> writes:

> * lisp/org-src.el (org-src--construct-edit-buffer-name): Fix the name
> given to a source editing buffer.  The original format was documented
> as "ORG-BUFFER-NAME [ LANG ]" but in reality it was "ORG-BUFFER-NAME[
> LANG ]", with different spacing.  We make the format more standard and
> more compact, as well as, make the documentation match reality.

Could you elaborate about "more standard"?
A safer way to fix the inconsistency in the docstring would be updating
the docstring to reflect the reality.


-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] org-src: Improve the name of source editing buffers
  2023-03-07 13:13   ` Ihor Radchenko
@ 2023-03-07 21:15     ` Rudolf Adamkovič
  2023-03-08 13:51       ` Ihor Radchenko
  0 siblings, 1 reply; 9+ messages in thread
From: Rudolf Adamkovič @ 2023-03-07 21:15 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode

Ihor Radchenko <yantar92@posteo.net> writes:

> Could you elaborate about "more standard"?

Sure.  For example, when I look at my Mode Line now, I see that the major more
is "Message[Notmuch]".  When I look at the names of the currently open buffers,
I see "FOO" and "{FOO}" and "[FOO] BAR" and "FOO(BAR)".  All this is "standard"
in Emacs.  I have yet to see a buffer, or anything else, named `FOO BAR[ BAZ ]'.

> A safer way to fix the inconsistency in the docstring would be updating
> the docstring to reflect the reality.

But misses the point, for I set out to fix the name itself.  I noticed the
documentation error only after the fact.

Every time I see "Org Src FOO BAR[ BAZ ]", it makes me think for a moment that I
must have misconfigured the mode line string or something.  And why?  Because it
looks "non-standard", like nothing else.

Rudy
-- 
"It is no paradox to say that in our most theoretical moods we may be
nearest to our most practical applications."
-- Alfred North Whitehead, 1861-1947

Rudolf Adamkovič <salutis@me.com> [he/him]
Studenohorská 25
84103 Bratislava
Slovakia


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] org-src: Improve the name of source editing buffers
  2023-03-07 21:15     ` Rudolf Adamkovič
@ 2023-03-08 13:51       ` Ihor Radchenko
  2023-03-08 22:02         ` Rudolf Adamkovič
  0 siblings, 1 reply; 9+ messages in thread
From: Ihor Radchenko @ 2023-03-08 13:51 UTC (permalink / raw)
  To: Rudolf Adamkovič; +Cc: emacs-orgmode

Rudolf Adamkovič <salutis@me.com> writes:

> Ihor Radchenko <yantar92@posteo.net> writes:
>
>> Could you elaborate about "more standard"?
>
> Sure.  For example, when I look at my Mode Line now, I see that the major more
> is "Message[Notmuch]".  When I look at the names of the currently open buffers,
> I see "FOO" and "{FOO}" and "[FOO] BAR" and "FOO(BAR)".  All this is "standard"
> in Emacs.  I have yet to see a buffer, or anything else, named `FOO BAR[ BAZ ]'.

net-utils.el also has "*ftp [host]*". Notably, with space.
I found no other use of [...] in Emacs sources.

I can see Message[Notmuch] in notmuch third-party package. But it is not
a buffer name.

Could you list other packages that use Foo[bar] pattern in buffer names?

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] org-src: Improve the name of source editing buffers
  2023-03-08 13:51       ` Ihor Radchenko
@ 2023-03-08 22:02         ` Rudolf Adamkovič
  2023-03-10 11:12           ` Ihor Radchenko
  0 siblings, 1 reply; 9+ messages in thread
From: Rudolf Adamkovič @ 2023-03-08 22:02 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode

Ihor Radchenko <yantar92@posteo.net> writes:

> net-utils.el also has "*ftp [host]*". Notably, with space.
> I found no other use of [...] in Emacs sources.

Looking at my buffers, I see:

- e.g. "FILE<PROJECT>" from Project.el
- e.g. "*EGLOT (PROJECT/(MODE)) events*" from Eglot
- e.g. "magit-diff(FILE1 -- FILE2): PROJECT" from Magit

All "normal looking" (spacing-wise), unlike e.g. "*Org Src FILE[ MODE ]*".

> Could you list other packages that use Foo[bar] pattern in buffer names?

Most packages use (), but I went with a minimal change, fixing just the weird
use of whitespace.

P.S. <> is for projects, so we should not use that, IMO.

Rudy
-- 
"'Contrariwise,' continued Tweedledee, 'if it was so, it might be; and
if it were so, it would be; but as it isn't, it ain't.  That's logic.'"
-- Lewis Carroll, Through the Looking Glass, 1871/1872

Rudolf Adamkovič <salutis@me.com> [he/him]
Studenohorská 25
84103 Bratislava
Slovakia


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] org-src: Improve the name of source editing buffers
  2023-03-08 22:02         ` Rudolf Adamkovič
@ 2023-03-10 11:12           ` Ihor Radchenko
  2023-03-14 20:55             ` Rudolf Adamkovič
  0 siblings, 1 reply; 9+ messages in thread
From: Ihor Radchenko @ 2023-03-10 11:12 UTC (permalink / raw)
  To: Rudolf Adamkovič; +Cc: emacs-orgmode

Rudolf Adamkovič <salutis@me.com> writes:

> - e.g. "FILE<PROJECT>" from Project.el
> - e.g. "*EGLOT (PROJECT/(MODE)) events*" from Eglot
> - e.g. "magit-diff(FILE1 -- FILE2): PROJECT" from Magit
>
> All "normal looking" (spacing-wise), unlike e.g. "*Org Src FILE[ MODE ]*".
> ....
>> Could you list other packages that use Foo[bar] pattern in buffer names?
>
> Most packages use (), but I went with a minimal change, fixing just the weird
> use of whitespace.

I see no logical reason why we should prefer " " over "".
It does not sound any stronger than preferring "[" over "(".
So, removing spaces is just a matter of preference.

Since the proposed patch is just a matter of preference, considering
that it may affect existing uses of `display-buffer-alist', I do not think
that the change is justified. Unless we have a large number of users
liking no spaces more.

For now, I just updated the docstring to reflect the reality.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=dd25e2704

Canceled.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] org-src: Improve the name of source editing buffers
  2023-03-10 11:12           ` Ihor Radchenko
@ 2023-03-14 20:55             ` Rudolf Adamkovič
  0 siblings, 0 replies; 9+ messages in thread
From: Rudolf Adamkovič @ 2023-03-14 20:55 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode

Ihor Radchenko <yantar92@posteo.net> writes:

> [...] it may affect existing uses of `display-buffer-alist' [...]  Canceled.

Yeah, I did not realize it would be a breaking change.

Thank you folks for discussing my patch!

Rudy
-- 
"Be especially critical of any statement following the word
'obviously.'"
-- Anna Pell Wheeler, 1883-1966

Rudolf Adamkovič <salutis@me.com> [he/him]
Studenohorská 25
84103 Bratislava
Slovakia


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-03-14 20:56 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-02 14:02 [PATCH] org-src: Improve the name of source editing buffers Rudolf Adamkovič
2023-03-05 21:26 ` Rudolf Adamkovič
2023-03-06 12:09   ` Max Nikulin
2023-03-07 13:13   ` Ihor Radchenko
2023-03-07 21:15     ` Rudolf Adamkovič
2023-03-08 13:51       ` Ihor Radchenko
2023-03-08 22:02         ` Rudolf Adamkovič
2023-03-10 11:12           ` Ihor Radchenko
2023-03-14 20:55             ` Rudolf Adamkovič

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.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).