* Bug: (org-set-tags t t) gives an error point is not currently on a headline
@ 2010-04-08 18:11 Ryan Thompson
2010-04-13 7:09 ` Carsten Dominik
0 siblings, 1 reply; 2+ messages in thread
From: Ryan Thompson @ 2010-04-08 18:11 UTC (permalink / raw)
To: Org-Mode List
[-- Attachment #1: Type: text/plain, Size: 413 bytes --]
Hi,
When I run (org-set-tags t t) to realign all tags in the buffer, it
doesn't work unless the point is currently on a headline, because
org-set-tags calls (org-get-tags-string) early on, and
org-get-tags-string raises an error if not on a headline. This can be
fixed by moving the binding of `current' to `(org-get-tags-string)'
into the else clause of the first if statment. I have attached a patch
-Ryan
--
[-- Attachment #2: fix-org-set-tags-with-prefix.diff --]
[-- Type: text/x-patch, Size: 6528 bytes --]
diff --git a/lisp/org.el b/lisp/org.el
index dc45871..1745116 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -12113,7 +12113,7 @@ If DATA is nil or the empty string, any tags will be removed."
With prefix ARG, realign all tags in headings in the current buffer."
(interactive "P")
(let* ((re (concat "^" outline-regexp))
- (current (org-get-tags-string))
+ ;(current (org-get-tags-string))
(col (current-column))
(org-setting-tags t)
table current-tags inherited-tags ; computed below when needed
@@ -12126,68 +12126,71 @@ With prefix ARG, realign all tags in headings in the current buffer."
(org-set-tags nil t)
(end-of-line 1)))
(message "All tags realigned to column %d" org-tags-column))
- (if just-align
- (setq tags current)
- ;; Get a new set of tags from the user
- (save-excursion
- (setq table (append org-tag-persistent-alist
- (or org-tag-alist (org-get-buffer-tags))
- (and org-complete-tags-always-offer-all-agenda-tags
- (org-global-tags-completion-table (org-agenda-files))))
- org-last-tags-completion-table table
- current-tags (org-split-string current ":")
- inherited-tags (nreverse
- (nthcdr (length current-tags)
- (nreverse (org-get-tags-at))))
- tags
- (if (or (eq t org-use-fast-tag-selection)
- (and org-use-fast-tag-selection
- (delq nil (mapcar 'cdr table))))
- (org-fast-tag-selection
- current-tags inherited-tags table
- (if org-fast-tag-selection-include-todo org-todo-key-alist))
- (let ((org-add-colon-after-tag-completion t))
- (org-trim
- (org-without-partial-completion
- (org-icompleting-read "Tags: " 'org-tags-completion-function
- nil nil current 'org-tags-history)))))))
- (while (string-match "[-+&]+" tags)
- ;; No boolean logic, just a list
- (setq tags (replace-match ":" t t tags))))
-
- (if org-tags-sort-function
- (setq tags (mapconcat 'identity
- (sort (org-split-string tags (org-re "[^[:alnum:]_@]+"))
- org-tags-sort-function) ":")))
-
- (if (string-match "\\`[\t ]*\\'" tags)
- (setq tags "")
- (unless (string-match ":$" tags) (setq tags (concat tags ":")))
- (unless (string-match "^:" tags) (setq tags (concat ":" tags))))
-
- ;; Insert new tags at the correct column
- (beginning-of-line 1)
- (cond
- ((and (equal current "") (equal tags "")))
- ((re-search-forward
- (concat "\\([ \t]*" (regexp-quote current) "\\)[ \t]*$")
- (point-at-eol) t)
- (if (equal tags "")
- (setq rpl "")
- (goto-char (match-beginning 0))
- (setq c0 (current-column) p0 (if (equal (char-before) ?*)
- (1+ (point)) (point))
- c1 (max (1+ c0) (if (> org-tags-column 0)
- org-tags-column
- (- (- org-tags-column) (length tags))))
- rpl (concat (make-string (max 0 (- c1 c0)) ?\ ) tags)))
- (replace-match rpl t t)
- (and (not (featurep 'xemacs)) c0 indent-tabs-mode (tabify p0 (point)))
- tags)
- (t (error "Tags alignment failed")))
- (org-move-to-column col)
- (unless just-align
- (run-hooks 'org-after-tags-change-hook)))))
+ ;(let ((current (unless arg (org-get-tags-string))))
+ (let ((current (org-get-tags-string)))
+ (if just-align
+
+ (setq tags current)
+ ;; Get a new set of tags from the user
+ (save-excursion
+ (setq table (append org-tag-persistent-alist
+ (or org-tag-alist (org-get-buffer-tags))
+ (and org-complete-tags-always-offer-all-agenda-tags
+ (org-global-tags-completion-table (org-agenda-files))))
+ org-last-tags-completion-table table
+ current-tags (org-split-string current ":")
+ inherited-tags (nreverse
+ (nthcdr (length current-tags)
+ (nreverse (org-get-tags-at))))
+ tags
+ (if (or (eq t org-use-fast-tag-selection)
+ (and org-use-fast-tag-selection
+ (delq nil (mapcar 'cdr table))))
+ (org-fast-tag-selection
+ current-tags inherited-tags table
+ (if org-fast-tag-selection-include-todo org-todo-key-alist))
+ (let ((org-add-colon-after-tag-completion t))
+ (org-trim
+ (org-without-partial-completion
+ (org-icompleting-read "Tags: " 'org-tags-completion-function
+ nil nil current 'org-tags-history)))))))
+ (while (string-match "[-+&]+" tags)
+ ;; No boolean logic, just a list
+ (setq tags (replace-match ":" t t tags))))
+
+ (if org-tags-sort-function
+ (setq tags (mapconcat 'identity
+ (sort (org-split-string tags (org-re "[^[:alnum:]_@]+"))
+ org-tags-sort-function) ":")))
+
+ (if (string-match "\\`[\t ]*\\'" tags)
+ (setq tags "")
+ (unless (string-match ":$" tags) (setq tags (concat tags ":")))
+ (unless (string-match "^:" tags) (setq tags (concat ":" tags))))
+
+ ;; Insert new tags at the correct column
+ (beginning-of-line 1)
+ (cond
+ ((and (equal current "") (equal tags "")))
+ ((re-search-forward
+ (concat "\\([ \t]*" (regexp-quote current) "\\)[ \t]*$")
+ (point-at-eol) t)
+ (if (equal tags "")
+ (setq rpl "")
+ (goto-char (match-beginning 0))
+ (setq c0 (current-column) p0 (if (equal (char-before) ?*)
+ (1+ (point)) (point))
+ c1 (max (1+ c0) (if (> org-tags-column 0)
+ org-tags-column
+ (- (- org-tags-column) (length tags))))
+ rpl (concat (make-string (max 0 (- c1 c0)) ?\ ) tags)))
+ (replace-match rpl t t)
+ (and (not (featurep 'xemacs)) c0 indent-tabs-mode (tabify p0 (point)))
+ tags)
+ (t (error "Tags alignment failed")))
+ (org-move-to-column col)
+ (unless just-align
+ (run-hooks 'org-after-tags-change-hook))))))
(defun org-change-tag-in-region (beg end tag off)
"Add or remove TAG for each entry in the region.
[-- Attachment #3: Type: text/plain, Size: 201 bytes --]
_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: Bug: (org-set-tags t t) gives an error point is not currently on a headline
2010-04-08 18:11 Bug: (org-set-tags t t) gives an error point is not currently on a headline Ryan Thompson
@ 2010-04-13 7:09 ` Carsten Dominik
0 siblings, 0 replies; 2+ messages in thread
From: Carsten Dominik @ 2010-04-13 7:09 UTC (permalink / raw)
To: Ryan Thompson; +Cc: Org-Mode List
Hi Ryan,
thanks for this patch.
I ended up to instead provide a special command to align
all tags, because org-set-tags should throw an error when
called not on a headline, for other reasons.
I am assuming that you want to call this from some lisp function - so
(org-align-all-tags)
should now do the job for you.
HTH. and thanks again.
- Carsten
On Apr 8, 2010, at 8:11 PM, Ryan Thompson wrote:
> Hi,
>
> When I run (org-set-tags t t) to realign all tags in the buffer, it
> doesn't work unless the point is currently on a headline, because
> org-set-tags calls (org-get-tags-string) early on, and
> org-get-tags-string raises an error if not on a headline. This can be
> fixed by moving the binding of `current' to `(org-get-tags-string)'
> into the else clause of the first if statment. I have attached a patch
>
> -Ryan
> --
> <fix-org-set-tags-with-
> prefix.diff>_______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
- Carsten
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-04-13 7:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-08 18:11 Bug: (org-set-tags t t) gives an error point is not currently on a headline Ryan Thompson
2010-04-13 7:09 ` Carsten Dominik
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).