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
>From a831b9014b3aaef16846dca049882a485ebf1dd6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rudolf=20Adamkovi=C4=8D?= <salu...@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

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

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

Reply via email to