forked from mirrors/org-mode
lisp/org.el (org-set-tags): Simplify further
* lisp/org.el (org-set-tags): Use let* for c0 p0 c1 rpl di tc; Restructure so that no check on c0 is needed; Don't return a useless tags var from cond; Change and into an equivalent when.
This commit is contained in:
parent
ceae5d651b
commit
00142f4edf
28
lisp/org.el
28
lisp/org.el
|
@ -14985,22 +14985,28 @@ When JUST-ALIGN is non-nil, only align tags."
|
||||||
((re-search-forward
|
((re-search-forward
|
||||||
(concat "\\([ \t]*" (regexp-quote current) "\\)[ \t]*$")
|
(concat "\\([ \t]*" (regexp-quote current) "\\)[ \t]*$")
|
||||||
(point-at-eol) t)
|
(point-at-eol) t)
|
||||||
(let (c0 p0 c1 rpl di tc)
|
|
||||||
(if (equal tags "")
|
(if (equal tags "")
|
||||||
(setq rpl "")
|
(replace-match "" t t)
|
||||||
(goto-char (match-beginning 0))
|
(goto-char (match-beginning 0))
|
||||||
(setq c0 (current-column)
|
(let* ((c0 (current-column))
|
||||||
;; compute offset for the case of org-indent-mode active
|
;; compute offset for the case of org-indent-mode active
|
||||||
di (if (org-bound-and-true-p org-indent-mode)
|
(di (if (org-bound-and-true-p org-indent-mode)
|
||||||
(* (1- org-indent-indentation-per-level) (1- level))
|
(* (1- org-indent-indentation-per-level) (1- level))
|
||||||
0)
|
0))
|
||||||
p0 (if (equal (char-before) ?*) (1+ (point)) (point))
|
(p0 (if (equal (char-before) ?*)
|
||||||
tc (+ org-tags-column (if (> org-tags-column 0) (- di) di))
|
(1+ (point))
|
||||||
c1 (max (1+ c0) (if (> tc 0) tc (- (- tc) (string-width tags))))
|
(point)))
|
||||||
rpl (concat (make-string (max 0 (- c1 c0)) ?\ ) tags)))
|
(tc (+ org-tags-column
|
||||||
|
(if (> org-tags-column 0)
|
||||||
|
(- di)
|
||||||
|
di)))
|
||||||
|
(c1 (max (1+ c0) (if (> tc 0)
|
||||||
|
tc
|
||||||
|
(- (- tc) (string-width tags)))))
|
||||||
|
(rpl (concat (make-string (max 0 (- c1 c0)) ?\ ) tags)))
|
||||||
(replace-match rpl t t)
|
(replace-match rpl t t)
|
||||||
(and (not (featurep 'xemacs)) c0 indent-tabs-mode (tabify p0 (point)))
|
(when (and (not (featurep 'xemacs)) indent-tabs-mode)
|
||||||
tags))
|
(tabify p0 (point))))))
|
||||||
(t (error "Tags alignment failed")))
|
(t (error "Tags alignment failed")))
|
||||||
(org-move-to-column col)
|
(org-move-to-column col)
|
||||||
(unless just-align
|
(unless just-align
|
||||||
|
|
Loading…
Reference in New Issue