[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org 9db57aee3e: Do not use visual `current-indentation'
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org 9db57aee3e: Do not use visual `current-indentation' when we need real values |
Date: |
Tue, 4 Oct 2022 03:57:52 -0400 (EDT) |
branch: externals/org
commit 9db57aee3e86dc47771840d21a19dc2e21e52299
Author: Ihor Radchenko <yantar92@gmail.com>
Commit: Ihor Radchenko <yantar92@gmail.com>
Do not use visual `current-indentation' when we need real values
* lisp/org-macs.el (org-current-text-indentation): New macro
calculating the real text indentation disregarding buffer visibility.
(org-do-remove-indentation):
* lisp/org-src.el (org-src--edit-element):
* lisp/org.el (org-indent-line):
(org-indent-region):
(org-toggle-fixed-width):
(org-comment-or-uncomment-region):
* lisp/ox.el (org-export-expand-include-keyword): Use
`org-current-text-indentation' instead of `current-indentation' and
`org-current-text-column' instead of `current-column' when we need
real text values but not visible values.
See https://debbugs.gnu.org/cgi/bugreport.cgi?bug=56837
Reported-by: tony aldon <tony.aldon.adm@gmail.com>
Link: https://orgmode.org/list/87k0h49s7z.fsf@localhost
---
lisp/ob-core.el | 4 ++--
lisp/ob-exp.el | 2 +-
lisp/oc.el | 2 +-
lisp/org-agenda.el | 4 ++--
lisp/org-capture.el | 2 +-
lisp/org-element.el | 4 ++--
lisp/org-list.el | 22 +++++++++++-----------
lisp/org-macs.el | 7 ++++++-
lisp/org-src.el | 4 ++--
lisp/org.el | 10 +++++-----
lisp/ox.el | 2 +-
11 files changed, 34 insertions(+), 29 deletions(-)
diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index 44b948145a..35d50e63e8 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -1982,7 +1982,7 @@ region is not active then the point is demarcated."
(save-excursion
(goto-char place)
(let ((lang (nth 0 info))
- (indent (make-string (current-indentation) ?\s)))
+ (indent (make-string (org-current-text-indentation) ?\s)))
(when (string-match "^[[:space:]]*$"
(buffer-substring (line-beginning-position)
(line-end-position)))
@@ -2740,7 +2740,7 @@ specified as an an \"attachment:\" style link."
(unless (eq (org-element-type element) 'src-block)
(error "Not in a source block"))
(goto-char (org-babel-where-is-src-block-head element))
- (let* ((ind (current-indentation))
+ (let* ((ind (org-current-text-indentation))
(body-start (line-beginning-position 2))
(body (org-element-normalize-string
(if (or org-src-preserve-indentation
diff --git a/lisp/ob-exp.el b/lisp/ob-exp.el
index d7aecde99e..0407272275 100644
--- a/lisp/ob-exp.el
+++ b/lisp/ob-exp.el
@@ -263,7 +263,7 @@ this template."
(insert rep))))
(`src-block
(let ((match-start (copy-marker (match-beginning 0)))
- (ind (current-indentation)))
+ (ind (org-current-text-indentation)))
;; Take care of matched block: compute
;; replacement string. In particular, a nil
;; REPLACEMENT means the block is left as-is
diff --git a/lisp/oc.el b/lisp/oc.el
index 10ca9d89f5..4d37601db7 100644
--- a/lisp/oc.el
+++ b/lisp/oc.el
@@ -1525,7 +1525,7 @@ CONTEXT is the element or object at point, as returned by
`org-element-context'.
;; unaffected.
((eq type 'item)
(> (point) (+ (org-element-property :begin context)
- (current-indentation)
+ (org-current-text-indentation)
(if (org-element-property :checkbox context)
5 1))))
;; Other elements are invalid.
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 2b56dd0fb2..5238d810ca 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -3748,10 +3748,10 @@ removed from the entry content. Currently only
`planning' is allowed here."
;; find and remove min common indentation
(goto-char (point-min))
(untabify (point-min) (point-max))
- (setq ind (current-indentation))
+ (setq ind (org-current-text-indentation))
(while (not (eobp))
(unless (looking-at "[ \t]*$")
- (setq ind (min ind (current-indentation))))
+ (setq ind (min ind (org-current-text-indentation))))
(beginning-of-line 2))
(goto-char (point-min))
(while (not (eobp))
diff --git a/lisp/org-capture.el b/lisp/org-capture.el
index 428d0ac0e2..eb7b9aaf6d 100644
--- a/lisp/org-capture.el
+++ b/lisp/org-capture.el
@@ -1275,7 +1275,7 @@ may have been stored before."
(when item
(let ((i (save-excursion
(goto-char (org-element-property :post-affiliated item))
- (current-indentation))))
+ (org-current-text-indentation))))
(save-excursion
(goto-char beg)
(save-excursion
diff --git a/lisp/org-element.el b/lisp/org-element.el
index e9e3a5128b..51d94fc2f9 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -1616,7 +1616,7 @@ CONTENTS is the contents of the element."
;; At a new item: end previous sibling.
((looking-at item-re)
(let ((ind (save-excursion (skip-chars-forward " \t")
- (current-column))))
+ (org-current-text-column))))
(setq top-ind (min top-ind ind))
(while (and items (<= ind (nth 1 (car items))))
(let ((item (pop items)))
@@ -1650,7 +1650,7 @@ CONTENTS is the contents of the element."
(t
(let ((ind (save-excursion
(skip-chars-forward " \t")
- (current-column)))
+ (org-current-text-column)))
(end (save-excursion
(skip-chars-backward " \r\t\n")
(line-beginning-position 2))))
diff --git a/lisp/org-list.el b/lisp/org-list.el
index 4867c62402..3f5314ab69 100644
--- a/lisp/org-list.el
+++ b/lisp/org-list.el
@@ -411,7 +411,7 @@ group 4: description tag")
(ind-ref (if (or (looking-at "^[ \t]*$")
(and inlinetask-re (looking-at inlinetask-re)))
10000
- (current-indentation))))
+ (org-current-text-indentation))))
(cond
((eq (nth 2 context) 'invalid) nil)
((looking-at item-re) (point))
@@ -433,7 +433,7 @@ group 4: description tag")
;; Look for an item, less indented that reference line.
(catch 'exit
(while t
- (let ((ind (current-indentation)))
+ (let ((ind (org-current-text-indentation)))
(cond
;; This is exactly what we want.
((and (looking-at item-re) (< ind ind-ref))
@@ -603,7 +603,7 @@ Assume point is at an item."
(item-re (org-item-re))
(inlinetask-re (and (featurep 'org-inlinetask)
(org-inlinetask-outline-regexp)))
- (beg-cell (cons (point) (current-indentation)))
+ (beg-cell (cons (point) (org-current-text-indentation)))
itm-lst itm-lst-2 end-lst end-lst-2 struct
(assoc-at-point
;; Return association at point.
@@ -629,7 +629,7 @@ Assume point is at an item."
(save-excursion
(catch 'exit
(while t
- (let ((ind (current-indentation)))
+ (let ((ind (org-current-text-indentation)))
(cond
((<= (point) lim-up)
;; At upward limit: if we ended at an item, store it,
@@ -689,7 +689,7 @@ Assume point is at an item."
;; position of items in END-LST-2.
(catch 'exit
(while t
- (let ((ind (current-indentation)))
+ (let ((ind (org-current-text-indentation)))
(cond
((>= (point) lim-down)
;; At downward limit: this is de facto the end of the
@@ -1840,7 +1840,7 @@ Initial position of cursor is restored after the changes."
(org-inlinetask-goto-beginning))
;; Shift only non-empty lines.
((looking-at-p "^[ \t]*\\S-")
- (indent-line-to (+ (current-indentation) delta))))
+ (indent-line-to (+ (org-current-text-indentation) delta))))
(forward-line -1))))
(modify-item
;; Replace ITEM first line elements with new elements from
@@ -1848,7 +1848,7 @@ Initial position of cursor is restored after the changes."
(lambda (item)
(goto-char item)
(let* ((new-ind (org-list-get-ind item struct))
- (old-ind (current-indentation))
+ (old-ind (org-current-text-indentation))
(new-bul (org-list-bullet-string
(org-list-get-bullet item struct)))
(old-bul (org-list-get-bullet item old-struct))
@@ -1938,7 +1938,7 @@ Initial position of cursor is restored after the changes."
;; Ignore empty lines. Also ignore blocks and
;; drawers contents.
(unless (looking-at-p "[ \t]*$")
- (setq min-ind (min (current-indentation) min-ind))
+ (setq min-ind (min (org-current-text-indentation)
min-ind))
(cond
((and (looking-at "#\\+BEGIN\\(:\\|_\\S-+\\)")
(re-search-forward
@@ -3031,7 +3031,7 @@ With a prefix argument ARG, change the region in a single
item."
(save-excursion
(catch 'exit
(while (< (point) end)
- (let ((i (current-indentation)))
+ (let ((i (org-current-text-indentation)))
(cond
;; Skip blank lines and inline tasks.
((looking-at "^[ \t]*$"))
@@ -3047,7 +3047,7 @@ With a prefix argument ARG, change the region in a single
item."
(while (< (point) end)
(unless (or (looking-at "^[ \t]*$")
(looking-at org-outline-regexp-bol))
- (indent-line-to (+ (current-indentation) delta)))
+ (indent-line-to (+ (org-current-text-indentation) delta)))
(forward-line))))))
(skip-blanks
(lambda (pos)
@@ -3139,7 +3139,7 @@ With a prefix argument ARG, change the region in a single
item."
;; set them as item's body.
(arg (let* ((bul (org-list-bullet-string "-"))
(bul-len (length bul))
- (ref-ind (current-indentation)))
+ (ref-ind (org-current-text-indentation)))
(skip-chars-forward " \t")
(insert bul)
(forward-line)
diff --git a/lisp/org-macs.el b/lisp/org-macs.el
index bbd7a4f831..74952aef3a 100644
--- a/lisp/org-macs.el
+++ b/lisp/org-macs.el
@@ -400,7 +400,7 @@ line. Return nil if it fails."
(save-excursion
(when skip-fl (forward-line))
(while (re-search-forward "^[ \t]*\\S-" nil t)
- (let ((ind (current-indentation)))
+ (let ((ind (org-current-text-indentation)))
(if (zerop ind) (throw :exit nil)
(setq min-ind (min min-ind ind))))))
min-ind))))
@@ -1101,6 +1101,11 @@ Return width in pixels when PIXELS is non-nil."
`(string-width (buffer-substring-no-properties
(line-beginning-position) (point))))
+(defmacro org-current-text-indentation ()
+ "Like `current-indentation', but ignore display/invisible properties."
+ `(let ((buffer-invisibility-spec nil))
+ (current-indentation)))
+
(defun org-not-nil (v)
"If V not nil, and also not the string \"nil\", then return V.
Otherwise return nil."
diff --git a/lisp/org-src.el b/lisp/org-src.el
index 96370bf71c..2d851611cb 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -533,11 +533,11 @@ Leave point in edit buffer."
(block-ind (org-with-point-at (org-element-property :begin datum)
(cond
((save-excursion (skip-chars-backward " \t") (bolp))
- (current-indentation))
+ (org-current-text-indentation))
((org-element-property :parent datum)
(org--get-expected-indentation
(org-element-property :parent datum) nil))
- (t (current-indentation)))))
+ (t (org-current-text-indentation)))))
(content-ind org-edit-src-content-indentation)
(blank-line (save-excursion (beginning-of-line)
(looking-at-p "^[[:space:]]*$")))
diff --git a/lisp/org.el b/lisp/org.el
index d438e76b1f..545ca36cd8 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -18818,13 +18818,13 @@ Also align node properties according to
`org-property-format'."
(let ((element (org-element-at-point))
block-content-ind some-ind)
(org-with-point-at (org-element-property :begin element)
- (setq block-content-ind (+ (current-indentation)
+ (setq block-content-ind (+ (org-current-text-indentation)
org-edit-src-content-indentation))
(forward-line)
(save-match-data (re-search-forward "^[ \t]*\\S-" nil t))
(backward-char)
(setq some-ind (if (looking-at-p "#\\+end_src")
- block-content-ind
(current-indentation))))
+ block-content-ind
(org-current-text-indentation))))
(indent-line-to (min block-content-ind some-ind))))
(org-babel-do-key-sequence-in-edit-buffer (kbd "TAB")))
(t
@@ -18933,7 +18933,7 @@ assumed to be significant there."
;; might break the list as a whole. On the other
;; hand, when at a plain list, indent it as a whole.
(cond ((eq type 'plain-list)
- (let ((offset (- ind (current-indentation))))
+ (let ((offset (- ind (org-current-text-indentation))))
(unless (zerop offset)
(indent-rigidly (org-element-property :begin element)
(org-element-property :end element)
@@ -19393,7 +19393,7 @@ region only contains such lines."
(catch 'zerop
(while (< (point) end)
(unless (looking-at-p "[ \t]*$")
- (let ((ind (current-indentation)))
+ (let ((ind (org-current-text-indentation)))
(setq min-ind (min min-ind ind))
(when (zerop ind) (throw 'zerop t))))
(forward-line)))))
@@ -19599,7 +19599,7 @@ strictly within a source block, use appropriate comment
syntax."
(goto-char (point-min))
(while (and (not (eobp)) (not (zerop min-indent)))
(unless (looking-at "[ \t]*$")
- (setq min-indent (min min-indent (current-indentation))))
+ (setq min-indent (min min-indent
(org-current-text-indentation))))
(forward-line)))
;; Then loop over all lines.
(save-excursion
diff --git a/lisp/ox.el b/lisp/ox.el
index 42204ffdea..51145acaa5 100644
--- a/lisp/ox.el
+++ b/lisp/ox.el
@@ -3236,7 +3236,7 @@ storing and resolving footnotes. It is created
automatically."
(beginning-of-line)
;; Extract arguments from keyword's value.
(let* ((value (org-element-property :value element))
- (ind (current-indentation))
+ (ind (org-current-text-indentation))
location
(coding-system-for-read
(or (and (string-match ":coding +\\(\\S-+\\)>" value)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/org 9db57aee3e: Do not use visual `current-indentation' when we need real values,
ELPA Syncer <=