emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/org a303a794f8: Support interactive editing of comment


From: ELPA Syncer
Subject: [elpa] externals/org a303a794f8: Support interactive editing of comment blocks
Date: Sun, 7 Aug 2022 05:57:50 -0400 (EDT)

branch: externals/org
commit a303a794f8c6f880aa8dc46f10179890bfd27423
Author: Ihor Radchenko <yantar92@gmail.com>
Commit: Ihor Radchenko <yantar92@gmail.com>

    Support interactive editing of comment blocks
    
    * lisp/org-src.el (org-edit-comment-block): New command to edit
    comment block elements.  The command auto-escapes Org markup inside.
    (org-src--contents-area):
    * lisp/org.el (org-insert-structure-template):
    (org-edit-special): Support comment blocks.
    * etc/ORG-NEWS (Interactive commands now support escaping text inside
    comment blocks):
    (New command ~org-edit-comment-block~ to edit comment block at point):
    Document the new features.
    
    See https://orgmode.org/list/87y1wc3ruw.fsf@mat.ucm.es
---
 etc/ORG-NEWS    | 19 ++++++++++++++++++-
 lisp/org-src.el | 25 ++++++++++++++++++++++++-
 lisp/org.el     |  5 ++++-
 3 files changed, 46 insertions(+), 3 deletions(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 947bf43754..00fe101dc9 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -141,6 +141,14 @@ discouraged when working with Org files.
 
 ** New features
 
+*** Interactive commands now support escaping text inside comment blocks
+
+~org-edit-special~ and ~org-insert-structure-template~ now handle
+comment blocks.
+
+See [[*New command ~org-edit-comment-block~ to edit comment block at
+point]].
+
 *** New customization option =org-property-separators=
 A new alist variable to control how properties are combined.
 
@@ -301,6 +309,16 @@ inside entry.  This was the default previously.
 
 Now, ~org-fold-show-entry~ does not fold drawers by default.
 
+*** New command ~org-edit-comment-block~ to edit comment block at point
+
+As the contents of comments blocks is not parsed as Org markup, the
+headlines and keywords inside should be escaped, similar to src
+blocks, example blocks, and export blocks.  This in inconvenient to do
+manually and ~org-edit-special~ is usually advised to edit text in
+such kind of blocks.
+
+Now, comment block editing is also supported via this new function.
+
 *** New function ~org-element-cache-map~ for quick mapping across Org elements
 
 When element cache is enabled, the new function provides the best
@@ -314,7 +332,6 @@ to ~org-element--cache-map-statistics~ and
 ~org-element--cache-map-statistics-threshold~.
 
 ~org-scan-tags~ and tag views in agenda utilise the new function.
-
 *** New function ~org-element-at-point-no-context~
 
 This function is like ~org-element-at-point~, but it does not try to
diff --git a/lisp/org-src.el b/lisp/org-src.el
index b7e0af50e6..0249af60b2 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -384,7 +384,7 @@ where BEG and END are buffer positions and CONTENTS is a 
string."
        (let ((beg (org-element-property :contents-begin datum))
             (end (org-element-property :contents-end datum)))
         (list beg end (buffer-substring-no-properties beg end))))
-      ((memq type '(example-block export-block src-block))
+      ((memq type '(example-block export-block src-block comment-block))
        (list (progn (goto-char (org-element-property :post-affiliated datum))
                    (line-beginning-position 2))
             (progn (goto-char (org-element-property :end datum))
@@ -1161,6 +1161,29 @@ Throw an error when not at an export block."
        (lambda () (org-escape-code-in-region (point-min) (point-max)))))
     t))
 
+(defun org-edit-comment-block ()
+  "Edit comment block at point.
+\\<org-src-mode-map>
+A new buffer is created and the block is copied into it, and the
+buffer is switched into Org mode.
+
+When done, exit with `\\[org-edit-src-exit]'.  The edited text \
+will then replace the area in the Org mode buffer.
+
+Throw an error when not at a comment block."
+  (interactive)
+  (let ((element (org-element-at-point)))
+    (unless (and (eq (org-element-type element) 'comment-block)
+                (org-src--on-datum-p element))
+      (user-error "Not in a comment block"))
+    (org-src--edit-element
+     element
+     (org-src--construct-edit-buffer-name (buffer-name) "org")
+     'org-mode
+     (lambda () (org-escape-code-in-region (point-min) (point-max)))
+     (org-unescape-code-in-string (org-element-property :value element)))
+    t))
+
 (defun org-edit-src-code (&optional code edit-buffer-name)
   "Edit the source or example block at point.
 \\<org-src-mode-map>
diff --git a/lisp/org.el b/lisp/org.el
index 602abf257e..8bc123e47e 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -8873,7 +8873,8 @@ When foo is written as FOO, upcase the #+BEGIN/END as 
well."
         (region-end (and region? (copy-marker (region-end))))
         (extended? (string-match-p "\\`\\(src\\|export\\)\\'" type))
         (verbatim? (string-match-p
-                    (concat "\\`" (regexp-opt '("example" "export" "src")))
+                    (concat "\\`" (regexp-opt '("example" "export"
+                                                "src" "comment")))
                     type))
          (upcase? (string= (car (split-string type))
                            (upcase (car (split-string type))))))
@@ -16998,6 +16999,7 @@ When at a table, call the formula editor with 
`org-table-edit-formulas'.
 When in a source code block, call `org-edit-src-code'.
 When in a fixed-width region, call `org-edit-fixed-width-region'.
 When in an export block, call `org-edit-export-block'.
+When in a comment block, call `org-edit-comment-block'.
 When in a LaTeX environment, call `org-edit-latex-environment'.
 When at an INCLUDE, SETUPFILE or BIBLIOGRAPHY keyword, visit the included file.
 When at a footnote reference, call `org-edit-footnote-reference'.
@@ -17044,6 +17046,7 @@ Otherwise, return a user error."
       (`table-row (call-interactively 'org-table-edit-formulas))
       (`example-block (org-edit-src-code))
       (`export-block (org-edit-export-block))
+      (`comment-block (org-edit-comment-block))
       (`fixed-width (org-edit-fixed-width-region))
       (`latex-environment (org-edit-latex-environment))
       (`planning



reply via email to

[Prev in Thread] Current Thread [Next in Thread]