mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-08-25 08:02:52 +00:00
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
This commit is contained in:
parent
0641ece57b
commit
9db57aee3e
|
@ -1982,7 +1982,7 @@ region is not active then the point is demarcated."
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(goto-char place)
|
(goto-char place)
|
||||||
(let ((lang (nth 0 info))
|
(let ((lang (nth 0 info))
|
||||||
(indent (make-string (current-indentation) ?\s)))
|
(indent (make-string (org-current-text-indentation) ?\s)))
|
||||||
(when (string-match "^[[:space:]]*$"
|
(when (string-match "^[[:space:]]*$"
|
||||||
(buffer-substring (line-beginning-position)
|
(buffer-substring (line-beginning-position)
|
||||||
(line-end-position)))
|
(line-end-position)))
|
||||||
|
@ -2740,7 +2740,7 @@ specified as an an \"attachment:\" style link."
|
||||||
(unless (eq (org-element-type element) 'src-block)
|
(unless (eq (org-element-type element) 'src-block)
|
||||||
(error "Not in a source block"))
|
(error "Not in a source block"))
|
||||||
(goto-char (org-babel-where-is-src-block-head element))
|
(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-start (line-beginning-position 2))
|
||||||
(body (org-element-normalize-string
|
(body (org-element-normalize-string
|
||||||
(if (or org-src-preserve-indentation
|
(if (or org-src-preserve-indentation
|
||||||
|
|
|
@ -263,7 +263,7 @@ this template."
|
||||||
(insert rep))))
|
(insert rep))))
|
||||||
(`src-block
|
(`src-block
|
||||||
(let ((match-start (copy-marker (match-beginning 0)))
|
(let ((match-start (copy-marker (match-beginning 0)))
|
||||||
(ind (current-indentation)))
|
(ind (org-current-text-indentation)))
|
||||||
;; Take care of matched block: compute
|
;; Take care of matched block: compute
|
||||||
;; replacement string. In particular, a nil
|
;; replacement string. In particular, a nil
|
||||||
;; REPLACEMENT means the block is left as-is
|
;; REPLACEMENT means the block is left as-is
|
||||||
|
|
|
@ -1525,7 +1525,7 @@ CONTEXT is the element or object at point, as returned by `org-element-context'.
|
||||||
;; unaffected.
|
;; unaffected.
|
||||||
((eq type 'item)
|
((eq type 'item)
|
||||||
(> (point) (+ (org-element-property :begin context)
|
(> (point) (+ (org-element-property :begin context)
|
||||||
(current-indentation)
|
(org-current-text-indentation)
|
||||||
(if (org-element-property :checkbox context)
|
(if (org-element-property :checkbox context)
|
||||||
5 1))))
|
5 1))))
|
||||||
;; Other elements are invalid.
|
;; Other elements are invalid.
|
||||||
|
|
|
@ -3748,10 +3748,10 @@ removed from the entry content. Currently only `planning' is allowed here."
|
||||||
;; find and remove min common indentation
|
;; find and remove min common indentation
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(untabify (point-min) (point-max))
|
(untabify (point-min) (point-max))
|
||||||
(setq ind (current-indentation))
|
(setq ind (org-current-text-indentation))
|
||||||
(while (not (eobp))
|
(while (not (eobp))
|
||||||
(unless (looking-at "[ \t]*$")
|
(unless (looking-at "[ \t]*$")
|
||||||
(setq ind (min ind (current-indentation))))
|
(setq ind (min ind (org-current-text-indentation))))
|
||||||
(beginning-of-line 2))
|
(beginning-of-line 2))
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(while (not (eobp))
|
(while (not (eobp))
|
||||||
|
|
|
@ -1275,7 +1275,7 @@ may have been stored before."
|
||||||
(when item
|
(when item
|
||||||
(let ((i (save-excursion
|
(let ((i (save-excursion
|
||||||
(goto-char (org-element-property :post-affiliated item))
|
(goto-char (org-element-property :post-affiliated item))
|
||||||
(current-indentation))))
|
(org-current-text-indentation))))
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(goto-char beg)
|
(goto-char beg)
|
||||||
(save-excursion
|
(save-excursion
|
||||||
|
|
|
@ -1616,7 +1616,7 @@ CONTENTS is the contents of the element."
|
||||||
;; At a new item: end previous sibling.
|
;; At a new item: end previous sibling.
|
||||||
((looking-at item-re)
|
((looking-at item-re)
|
||||||
(let ((ind (save-excursion (skip-chars-forward " \t")
|
(let ((ind (save-excursion (skip-chars-forward " \t")
|
||||||
(current-column))))
|
(org-current-text-column))))
|
||||||
(setq top-ind (min top-ind ind))
|
(setq top-ind (min top-ind ind))
|
||||||
(while (and items (<= ind (nth 1 (car items))))
|
(while (and items (<= ind (nth 1 (car items))))
|
||||||
(let ((item (pop items)))
|
(let ((item (pop items)))
|
||||||
|
@ -1650,7 +1650,7 @@ CONTENTS is the contents of the element."
|
||||||
(t
|
(t
|
||||||
(let ((ind (save-excursion
|
(let ((ind (save-excursion
|
||||||
(skip-chars-forward " \t")
|
(skip-chars-forward " \t")
|
||||||
(current-column)))
|
(org-current-text-column)))
|
||||||
(end (save-excursion
|
(end (save-excursion
|
||||||
(skip-chars-backward " \r\t\n")
|
(skip-chars-backward " \r\t\n")
|
||||||
(line-beginning-position 2))))
|
(line-beginning-position 2))))
|
||||||
|
|
|
@ -411,7 +411,7 @@ group 4: description tag")
|
||||||
(ind-ref (if (or (looking-at "^[ \t]*$")
|
(ind-ref (if (or (looking-at "^[ \t]*$")
|
||||||
(and inlinetask-re (looking-at inlinetask-re)))
|
(and inlinetask-re (looking-at inlinetask-re)))
|
||||||
10000
|
10000
|
||||||
(current-indentation))))
|
(org-current-text-indentation))))
|
||||||
(cond
|
(cond
|
||||||
((eq (nth 2 context) 'invalid) nil)
|
((eq (nth 2 context) 'invalid) nil)
|
||||||
((looking-at item-re) (point))
|
((looking-at item-re) (point))
|
||||||
|
@ -433,7 +433,7 @@ group 4: description tag")
|
||||||
;; Look for an item, less indented that reference line.
|
;; Look for an item, less indented that reference line.
|
||||||
(catch 'exit
|
(catch 'exit
|
||||||
(while t
|
(while t
|
||||||
(let ((ind (current-indentation)))
|
(let ((ind (org-current-text-indentation)))
|
||||||
(cond
|
(cond
|
||||||
;; This is exactly what we want.
|
;; This is exactly what we want.
|
||||||
((and (looking-at item-re) (< ind ind-ref))
|
((and (looking-at item-re) (< ind ind-ref))
|
||||||
|
@ -603,7 +603,7 @@ Assume point is at an item."
|
||||||
(item-re (org-item-re))
|
(item-re (org-item-re))
|
||||||
(inlinetask-re (and (featurep 'org-inlinetask)
|
(inlinetask-re (and (featurep 'org-inlinetask)
|
||||||
(org-inlinetask-outline-regexp)))
|
(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
|
itm-lst itm-lst-2 end-lst end-lst-2 struct
|
||||||
(assoc-at-point
|
(assoc-at-point
|
||||||
;; Return association at point.
|
;; Return association at point.
|
||||||
|
@ -629,7 +629,7 @@ Assume point is at an item."
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(catch 'exit
|
(catch 'exit
|
||||||
(while t
|
(while t
|
||||||
(let ((ind (current-indentation)))
|
(let ((ind (org-current-text-indentation)))
|
||||||
(cond
|
(cond
|
||||||
((<= (point) lim-up)
|
((<= (point) lim-up)
|
||||||
;; At upward limit: if we ended at an item, store it,
|
;; 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.
|
;; position of items in END-LST-2.
|
||||||
(catch 'exit
|
(catch 'exit
|
||||||
(while t
|
(while t
|
||||||
(let ((ind (current-indentation)))
|
(let ((ind (org-current-text-indentation)))
|
||||||
(cond
|
(cond
|
||||||
((>= (point) lim-down)
|
((>= (point) lim-down)
|
||||||
;; At downward limit: this is de facto the end of the
|
;; 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))
|
(org-inlinetask-goto-beginning))
|
||||||
;; Shift only non-empty lines.
|
;; Shift only non-empty lines.
|
||||||
((looking-at-p "^[ \t]*\\S-")
|
((looking-at-p "^[ \t]*\\S-")
|
||||||
(indent-line-to (+ (current-indentation) delta))))
|
(indent-line-to (+ (org-current-text-indentation) delta))))
|
||||||
(forward-line -1))))
|
(forward-line -1))))
|
||||||
(modify-item
|
(modify-item
|
||||||
;; Replace ITEM first line elements with new elements from
|
;; Replace ITEM first line elements with new elements from
|
||||||
|
@ -1848,7 +1848,7 @@ Initial position of cursor is restored after the changes."
|
||||||
(lambda (item)
|
(lambda (item)
|
||||||
(goto-char item)
|
(goto-char item)
|
||||||
(let* ((new-ind (org-list-get-ind item struct))
|
(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
|
(new-bul (org-list-bullet-string
|
||||||
(org-list-get-bullet item struct)))
|
(org-list-get-bullet item struct)))
|
||||||
(old-bul (org-list-get-bullet item old-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
|
;; Ignore empty lines. Also ignore blocks and
|
||||||
;; drawers contents.
|
;; drawers contents.
|
||||||
(unless (looking-at-p "[ \t]*$")
|
(unless (looking-at-p "[ \t]*$")
|
||||||
(setq min-ind (min (current-indentation) min-ind))
|
(setq min-ind (min (org-current-text-indentation) min-ind))
|
||||||
(cond
|
(cond
|
||||||
((and (looking-at "#\\+BEGIN\\(:\\|_\\S-+\\)")
|
((and (looking-at "#\\+BEGIN\\(:\\|_\\S-+\\)")
|
||||||
(re-search-forward
|
(re-search-forward
|
||||||
|
@ -3031,7 +3031,7 @@ With a prefix argument ARG, change the region in a single item."
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(catch 'exit
|
(catch 'exit
|
||||||
(while (< (point) end)
|
(while (< (point) end)
|
||||||
(let ((i (current-indentation)))
|
(let ((i (org-current-text-indentation)))
|
||||||
(cond
|
(cond
|
||||||
;; Skip blank lines and inline tasks.
|
;; Skip blank lines and inline tasks.
|
||||||
((looking-at "^[ \t]*$"))
|
((looking-at "^[ \t]*$"))
|
||||||
|
@ -3047,7 +3047,7 @@ With a prefix argument ARG, change the region in a single item."
|
||||||
(while (< (point) end)
|
(while (< (point) end)
|
||||||
(unless (or (looking-at "^[ \t]*$")
|
(unless (or (looking-at "^[ \t]*$")
|
||||||
(looking-at org-outline-regexp-bol))
|
(looking-at org-outline-regexp-bol))
|
||||||
(indent-line-to (+ (current-indentation) delta)))
|
(indent-line-to (+ (org-current-text-indentation) delta)))
|
||||||
(forward-line))))))
|
(forward-line))))))
|
||||||
(skip-blanks
|
(skip-blanks
|
||||||
(lambda (pos)
|
(lambda (pos)
|
||||||
|
@ -3139,7 +3139,7 @@ With a prefix argument ARG, change the region in a single item."
|
||||||
;; set them as item's body.
|
;; set them as item's body.
|
||||||
(arg (let* ((bul (org-list-bullet-string "-"))
|
(arg (let* ((bul (org-list-bullet-string "-"))
|
||||||
(bul-len (length bul))
|
(bul-len (length bul))
|
||||||
(ref-ind (current-indentation)))
|
(ref-ind (org-current-text-indentation)))
|
||||||
(skip-chars-forward " \t")
|
(skip-chars-forward " \t")
|
||||||
(insert bul)
|
(insert bul)
|
||||||
(forward-line)
|
(forward-line)
|
||||||
|
|
|
@ -400,7 +400,7 @@ line. Return nil if it fails."
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(when skip-fl (forward-line))
|
(when skip-fl (forward-line))
|
||||||
(while (re-search-forward "^[ \t]*\\S-" nil t)
|
(while (re-search-forward "^[ \t]*\\S-" nil t)
|
||||||
(let ((ind (current-indentation)))
|
(let ((ind (org-current-text-indentation)))
|
||||||
(if (zerop ind) (throw :exit nil)
|
(if (zerop ind) (throw :exit nil)
|
||||||
(setq min-ind (min min-ind ind))))))
|
(setq min-ind (min min-ind ind))))))
|
||||||
min-ind))))
|
min-ind))))
|
||||||
|
@ -1101,6 +1101,11 @@ Return width in pixels when PIXELS is non-nil."
|
||||||
`(string-width (buffer-substring-no-properties
|
`(string-width (buffer-substring-no-properties
|
||||||
(line-beginning-position) (point))))
|
(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)
|
(defun org-not-nil (v)
|
||||||
"If V not nil, and also not the string \"nil\", then return V.
|
"If V not nil, and also not the string \"nil\", then return V.
|
||||||
Otherwise return nil."
|
Otherwise return nil."
|
||||||
|
|
|
@ -533,11 +533,11 @@ Leave point in edit buffer."
|
||||||
(block-ind (org-with-point-at (org-element-property :begin datum)
|
(block-ind (org-with-point-at (org-element-property :begin datum)
|
||||||
(cond
|
(cond
|
||||||
((save-excursion (skip-chars-backward " \t") (bolp))
|
((save-excursion (skip-chars-backward " \t") (bolp))
|
||||||
(current-indentation))
|
(org-current-text-indentation))
|
||||||
((org-element-property :parent datum)
|
((org-element-property :parent datum)
|
||||||
(org--get-expected-indentation
|
(org--get-expected-indentation
|
||||||
(org-element-property :parent datum) nil))
|
(org-element-property :parent datum) nil))
|
||||||
(t (current-indentation)))))
|
(t (org-current-text-indentation)))))
|
||||||
(content-ind org-edit-src-content-indentation)
|
(content-ind org-edit-src-content-indentation)
|
||||||
(blank-line (save-excursion (beginning-of-line)
|
(blank-line (save-excursion (beginning-of-line)
|
||||||
(looking-at-p "^[[:space:]]*$")))
|
(looking-at-p "^[[:space:]]*$")))
|
||||||
|
|
10
lisp/org.el
10
lisp/org.el
|
@ -18818,13 +18818,13 @@ Also align node properties according to `org-property-format'."
|
||||||
(let ((element (org-element-at-point))
|
(let ((element (org-element-at-point))
|
||||||
block-content-ind some-ind)
|
block-content-ind some-ind)
|
||||||
(org-with-point-at (org-element-property :begin element)
|
(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))
|
org-edit-src-content-indentation))
|
||||||
(forward-line)
|
(forward-line)
|
||||||
(save-match-data (re-search-forward "^[ \t]*\\S-" nil t))
|
(save-match-data (re-search-forward "^[ \t]*\\S-" nil t))
|
||||||
(backward-char)
|
(backward-char)
|
||||||
(setq some-ind (if (looking-at-p "#\\+end_src")
|
(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))))
|
(indent-line-to (min block-content-ind some-ind))))
|
||||||
(org-babel-do-key-sequence-in-edit-buffer (kbd "TAB")))
|
(org-babel-do-key-sequence-in-edit-buffer (kbd "TAB")))
|
||||||
(t
|
(t
|
||||||
|
@ -18933,7 +18933,7 @@ assumed to be significant there."
|
||||||
;; might break the list as a whole. On the other
|
;; might break the list as a whole. On the other
|
||||||
;; hand, when at a plain list, indent it as a whole.
|
;; hand, when at a plain list, indent it as a whole.
|
||||||
(cond ((eq type 'plain-list)
|
(cond ((eq type 'plain-list)
|
||||||
(let ((offset (- ind (current-indentation))))
|
(let ((offset (- ind (org-current-text-indentation))))
|
||||||
(unless (zerop offset)
|
(unless (zerop offset)
|
||||||
(indent-rigidly (org-element-property :begin element)
|
(indent-rigidly (org-element-property :begin element)
|
||||||
(org-element-property :end element)
|
(org-element-property :end element)
|
||||||
|
@ -19393,7 +19393,7 @@ region only contains such lines."
|
||||||
(catch 'zerop
|
(catch 'zerop
|
||||||
(while (< (point) end)
|
(while (< (point) end)
|
||||||
(unless (looking-at-p "[ \t]*$")
|
(unless (looking-at-p "[ \t]*$")
|
||||||
(let ((ind (current-indentation)))
|
(let ((ind (org-current-text-indentation)))
|
||||||
(setq min-ind (min min-ind ind))
|
(setq min-ind (min min-ind ind))
|
||||||
(when (zerop ind) (throw 'zerop t))))
|
(when (zerop ind) (throw 'zerop t))))
|
||||||
(forward-line)))))
|
(forward-line)))))
|
||||||
|
@ -19599,7 +19599,7 @@ strictly within a source block, use appropriate comment syntax."
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(while (and (not (eobp)) (not (zerop min-indent)))
|
(while (and (not (eobp)) (not (zerop min-indent)))
|
||||||
(unless (looking-at "[ \t]*$")
|
(unless (looking-at "[ \t]*$")
|
||||||
(setq min-indent (min min-indent (current-indentation))))
|
(setq min-indent (min min-indent (org-current-text-indentation))))
|
||||||
(forward-line)))
|
(forward-line)))
|
||||||
;; Then loop over all lines.
|
;; Then loop over all lines.
|
||||||
(save-excursion
|
(save-excursion
|
||||||
|
|
|
@ -3236,7 +3236,7 @@ storing and resolving footnotes. It is created automatically."
|
||||||
(beginning-of-line)
|
(beginning-of-line)
|
||||||
;; Extract arguments from keyword's value.
|
;; Extract arguments from keyword's value.
|
||||||
(let* ((value (org-element-property :value element))
|
(let* ((value (org-element-property :value element))
|
||||||
(ind (current-indentation))
|
(ind (org-current-text-indentation))
|
||||||
location
|
location
|
||||||
(coding-system-for-read
|
(coding-system-for-read
|
||||||
(or (and (string-match ":coding +\\(\\S-+\\)>" value)
|
(or (and (string-match ":coding +\\(\\S-+\\)>" value)
|
||||||
|
|
Loading…
Reference in a new issue