* bug: org-mouse broken @ 2011-08-19 5:56 Samuel Wales 2011-08-19 6:06 ` Samuel Wales 2011-09-20 17:39 ` Samuel Wales 0 siblings, 2 replies; 17+ messages in thread From: Samuel Wales @ 2011-08-19 5:56 UTC (permalink / raw) To: emacs-orgmode mouse-1 on stars says "no link" sometimes instead of cycling. Maybe it is a regexp issue. git bisect: 628ebf04f74afa8694945386c507bde06c3aac9e is the first bad commit commit 628ebf04f74afa8694945386c507bde06c3aac9e Author: Nicolas Goaziou <n.goaziou@gmail.com> Date: Mon Jul 25 17:50:28 2011 +0200 Enforce white space after todo keywords * lisp/org.el (org-set-regexps-and-options): enforce white space after todo keyword, as word boundary isn't sufficient (i.e. in matches * TODO/this) :040000 040000 9786e7018273d86a894aecabac265e46429c233c ef1ffd65a9c8efa918dedfe5c157f0f1ef835923 M lisp I can't provide more at present, but thuoght this might help. Samuel -- The Kafka Pandemic: http://thekafkapandemic.blogspot.com I support the Whittemore-Peterson Institute (WPI) === Bigotry against people with serious diseases is still bigotry. ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: bug: org-mouse broken 2011-08-19 5:56 bug: org-mouse broken Samuel Wales @ 2011-08-19 6:06 ` Samuel Wales 2011-09-20 17:39 ` Samuel Wales 1 sibling, 0 replies; 17+ messages in thread From: Samuel Wales @ 2011-08-19 6:06 UTC (permalink / raw) To: emacs-orgmode On headlines without todo kw, tries to follow link. Should cycle. On 2011-08-18, Samuel Wales <samologist@gmail.com> wrote: > mouse-1 on stars says "no link" sometimes instead of cycling. > > Maybe it is a regexp issue. > > git bisect: > > 628ebf04f74afa8694945386c507bde06c3aac9e is the first bad commit > commit 628ebf04f74afa8694945386c507bde06c3aac9e > Author: Nicolas Goaziou <n.goaziou@gmail.com> > Date: Mon Jul 25 17:50:28 2011 +0200 > > Enforce white space after todo keywords > > * lisp/org.el (org-set-regexps-and-options): enforce white space after > todo keyword, as word boundary isn't sufficient (i.e. in matches > * TODO/this) > > :040000 040000 9786e7018273d86a894aecabac265e46429c233c > ef1ffd65a9c8efa918dedfe5c157f0f1ef835923 M lisp > > I can't provide more at present, but thuoght this might help. > > Samuel > > -- > The Kafka Pandemic: http://thekafkapandemic.blogspot.com > I support the Whittemore-Peterson Institute (WPI) > === > Bigotry against people with serious diseases is still bigotry. > -- The Kafka Pandemic: http://thekafkapandemic.blogspot.com I support the Whittemore-Peterson Institute (WPI) === Bigotry against people with serious diseases is still bigotry. ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: bug: org-mouse broken 2011-08-19 5:56 bug: org-mouse broken Samuel Wales 2011-08-19 6:06 ` Samuel Wales @ 2011-09-20 17:39 ` Samuel Wales 2011-09-20 17:42 ` Samuel Wales 1 sibling, 1 reply; 17+ messages in thread From: Samuel Wales @ 2011-09-20 17:39 UTC (permalink / raw) To: emacs-orgmode Org-mouse still broken. I wonder if it would be safe to revert this patch, or perhaps it's a bug in org-mouse. On 2011-08-18, Samuel Wales <samologist@gmail.com> wrote: > git bisect: > > 628ebf04f74afa8694945386c507bde06c3aac9e is the first bad commit > commit 628ebf04f74afa8694945386c507bde06c3aac9e > Author: Nicolas Goaziou <n.goaziou@gmail.com> > Date: Mon Jul 25 17:50:28 2011 +0200 > > Enforce white space after todo keywords > > * lisp/org.el (org-set-regexps-and-options): enforce white space after > todo keyword, as word boundary isn't sufficient (i.e. in matches > * TODO/this) > > :040000 040000 9786e7018273d86a894aecabac265e46429c233c > ef1ffd65a9c8efa918dedfe5c157f0f1ef835923 M lisp ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: bug: org-mouse broken 2011-09-20 17:39 ` Samuel Wales @ 2011-09-20 17:42 ` Samuel Wales 2011-09-22 14:19 ` Nicolas Goaziou 0 siblings, 1 reply; 17+ messages in thread From: Samuel Wales @ 2011-09-20 17:42 UTC (permalink / raw) To: emacs-orgmode To reproduce load org-mouse and mouse-1 in the stars: *** will say no links instead of cycle click in the stars ***** more no links instead of cycle more ***** more with links will do menu instead of cycle http://google.com/whatever http://google.com ***** more ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: bug: org-mouse broken 2011-09-20 17:42 ` Samuel Wales @ 2011-09-22 14:19 ` Nicolas Goaziou 2011-09-22 16:26 ` Michael Brand 0 siblings, 1 reply; 17+ messages in thread From: Nicolas Goaziou @ 2011-09-22 14:19 UTC (permalink / raw) To: Samuel Wales; +Cc: emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 569 bytes --] Hello, Samuel Wales <samologist@gmail.com> writes: > To reproduce load org-mouse and mouse-1 in the stars: > > *** will say no links instead of cycle > click in the stars > ***** more no links instead of cycle > more > ***** more with links will do menu instead of cycle > http://google.com/whatever > http://google.com > ***** more Could you try the following patch to see if it fixes your problem? It encompasses much more than a fix for this bug, so I would also appreciate if you could watch for abnormal behaviour while using it. Regards, -- Nicolas Goaziou [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: patch --] [-- Type: text/x-patch, Size: 24153 bytes --] From 328ef800314fc7f1a31c7111e396fe1a877b735e Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou <n.goaziou@gmail.com> Date: Thu, 25 Aug 2011 01:58:29 +0200 Subject: [PATCH] Provide more consistent regexps for headlines * lisp/org-agenda.el (org-search-view): simplify regexp. (org-agenda-get-todos): use new format string. * lisp/org-archive.el (org-archive-all-done): simplify regexp. * lisp/org-ascii.el (org-export-as-ascii): more accurate regexp. * lisp/org-colview-xemacs.el (org-columns-capture-view): use new format string and new string. * lisp/org-colview.el (org-columns-capture-view): use new format string and new string. * lisp/org-docbook.el (org-export-as-docbook): more accurate regexp. Also use new regexp to match generic headlines. * lisp/org-exp.el (org-export-protect-quoted-subtrees): more accurate regexp. Also use new regexp to match generic headlines. * lisp/org-html.el (org-export-as-html): more accurate regexp. Also use new regexp to match generic headlines. * lisp/org-mouse.el (org-mouse-match-todo-keyword): removed unused and now erroneous function. * lisp/org.el (org-heading-regexp, org-heading-keyword-regexp-format): new variables. (org-set-regexps-and-options): create regexps according to the following rule: use spaces only to separate elements from an headline, while allowing mixed tabs and spaces for any indentation job. (org-nl-done-regexp, org-looking-at-done-regexp): removed variables. (org-set-font-lock-defaults): fontify again headlines with a keyword and no other text. Use new format strings. (org-get-heading, org-toggle-comment, org-prepare-agenda-buffers, org-toggle-fixed-width-section): use new format string. (org-todo): more accurate regexps. (org-point-at-end-of-empty-headline): simplify regexp. This patch attempts to reduce the number of hard-coded headlines, by providing two format strings and one generic string to cover most of the cases of headline construction. --- lisp/org-agenda.el | 35 +++++---- lisp/org-archive.el | 2 +- lisp/org-ascii.el | 4 +- lisp/org-colview-xemacs.el | 5 +- lisp/org-colview.el | 5 +- lisp/org-docbook.el | 7 +- lisp/org-exp.el | 6 +- lisp/org-html.el | 7 +- lisp/org-mouse.el | 7 -- lisp/org.el | 188 +++++++++++++++++++++++++------------------- 10 files changed, 146 insertions(+), 120 deletions(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index b1fa5f5..28c5d44 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -3868,7 +3868,7 @@ in `org-agenda-text-search-extra-files'." (if (not regexps+) (setq regexp org-outline-regexp-bol) (setq regexp (pop regexps+)) - (if hdl-only (setq regexp (concat "^" org-outline-regexp ".*?" + (if hdl-only (setq regexp (concat org-outline-regexp-bol " .*?" regexp)))) (setq files (org-agenda-files nil 'ifmode)) (when (eq (car org-agenda-text-search-extra-files) 'agenda-archives) @@ -4574,18 +4574,21 @@ the documentation of `org-diary'." 'help-echo (format "mouse-2 or RET jump to org file %s" (abbreviate-file-name buffer-file-name)))) - (regexp (concat "^\\*+[ \t]+\\(" - (if org-select-this-todo-keyword - (if (equal org-select-this-todo-keyword "*") - org-todo-regexp - (concat "\\<\\(" - (mapconcat 'identity - (org-split-string - org-select-this-todo-keyword "|") "\\|") - "\\)\\>")) - org-not-done-regexp) - "[^\n\r]*\\)")) - marker priority category category-pos tags todo-state ee txt beg end) + (regexp (format org-heading-keyword-regexp-format + (cond + ((and org-select-this-todo-keyword + (equal org-select-this-todo-keyword "*")) + org-todo-regexp) + (org-select-this-todo-keyword + (concat "\\(" + (mapconcat 'identity + (org-split-string + org-select-this-todo-keyword + "|") + "\\|") "\\)")) + (t org-not-done-regexp)))) + marker priority category tags todo-state + ee txt beg end) (goto-char (point-min)) (while (re-search-forward regexp nil t) (catch :skip @@ -4597,11 +4600,11 @@ the documentation of `org-diary'." (goto-char (1+ beg)) (or org-agenda-todo-list-sublevels (org-end-of-subtree 'invisible)) (throw :skip nil))) - (goto-char (match-beginning 1)) + (goto-char (match-beginning 2)) (setq marker (org-agenda-new-marker (match-beginning 0)) category (org-get-category) category-pos (get-text-property (point) 'org-category-position) - txt (match-string 1) + txt (match-string 2) tags (org-get-tags-at (point)) txt (org-format-agenda-item "" txt category tags) priority (1+ (org-get-priority txt)) @@ -4613,7 +4616,7 @@ the documentation of `org-diary'." 'type "todo" 'todo-state todo-state) (push txt ee) (if org-agenda-todo-list-sublevels - (goto-char (match-end 1)) + (goto-char (match-end 2)) (org-end-of-subtree 'invisible)))) (nreverse ee))) diff --git a/lisp/org-archive.el b/lisp/org-archive.el index 16c35cf..c7a4049 100644 --- a/lisp/org-archive.el +++ b/lisp/org-archive.el @@ -404,7 +404,7 @@ sibling does not exist, it will be created at the end of the subtree." If the cursor is not on a headline, try all level 1 trees. If it is on a headline, try all direct children. When TAG is non-nil, don't move trees, but mark them with the ARCHIVE tag." - (let ((re (concat org-outline-regexp-bol "+" org-not-done-regexp)) re1 + (let ((re org-not-done-heading-regexp) re1 (rea (concat ".*:" org-archive-tag ":")) (begm (make-marker)) (endm (make-marker)) diff --git a/lisp/org-ascii.el b/lisp/org-ascii.el index 056f44b..2663886 100644 --- a/lisp/org-ascii.el +++ b/lisp/org-ascii.el @@ -283,7 +283,7 @@ publishing directory." "UNTITLED")) (email (plist-get opt-plist :email)) (language (plist-get opt-plist :language)) - (quote-re0 (concat "^[ \t]*" org-quote-string "\\>")) + (quote-re0 (concat "^\\(" org-quote-string "\\)\\( +\\|[ \t]*$\\)")) (todo nil) (lang-words nil) (region @@ -406,7 +406,7 @@ publishing directory." txt)) (setq txt (replace-match "" t t txt))) (if (string-match quote-re0 txt) - (setq txt (replace-match "" t t txt))) + (setq txt (replace-match "" t t txt 1))) (if org-export-with-section-numbers (setq txt (concat (org-section-number level) diff --git a/lisp/org-colview-xemacs.el b/lisp/org-colview-xemacs.el index b32e741..a85762f 100644 --- a/lisp/org-colview-xemacs.el +++ b/lisp/org-colview-xemacs.el @@ -1317,12 +1317,13 @@ of fields." (if (featurep 'xemacs) (save-excursion (let* ((title (mapcar 'cadr org-columns-current-fmt-compiled)) - (re-comment (concat "\\*+[ \t]+" org-comment-string "\\>")) + (re-comment (format org-heading-keyword-regexp-format + org-comment-string)) (re-archive (concat ".*:" org-archive-tag ":")) (n (length title)) row tbl) (goto-char (point-min)) - (while (re-search-forward "^\\(\\*+\\) " nil t) + (while (re-search-forward org-heading-regexp nil t) (catch 'next (when (and (or (null maxlevel) (>= maxlevel diff --git a/lisp/org-colview.el b/lisp/org-colview.el index 829a134..0635419 100644 --- a/lisp/org-colview.el +++ b/lisp/org-colview.el @@ -1152,11 +1152,12 @@ containing the title row and all other rows. Each row is a list of fields." (save-excursion (let* ((title (mapcar 'cadr org-columns-current-fmt-compiled)) - (re-comment (concat "\\*+[ \t]+" org-comment-string "\\>")) + (re-comment (format org-heading-keyword-regexp-format + org-comment-string)) (re-archive (concat ".*:" org-archive-tag ":")) (n (length title)) row tbl) (goto-char (point-min)) - (while (re-search-forward "^\\(\\*+\\) " nil t) + (while (re-search-forward org-heading-regexp nil t) (catch 'next (when (and (or (null maxlevel) (>= maxlevel diff --git a/lisp/org-docbook.el b/lisp/org-docbook.el index f09740f..2c997e4 100644 --- a/lisp/org-docbook.el +++ b/lisp/org-docbook.el @@ -498,8 +498,9 @@ publishing directory." ;; We will use HTML table formatter to export tables to DocBook ;; format, so need to set html-table-tag here. (html-table-tag (plist-get opt-plist :html-table-tag)) - (quote-re0 (concat "^[ \t]*" org-quote-string "\\>")) - (quote-re (concat "^\\(\\*+\\)\\([ \t]+" org-quote-string "\\>\\)")) + (quote-re0 (concat "^ *" org-quote-string "\\( +\\|[ \t]*$\\)")) + (quote-re (format org-heading-keyword-regexp-format + org-quote-string)) (inquote nil) (infixed nil) (inverse nil) @@ -969,7 +970,7 @@ publishing directory." (push (cons num 1) footref-seen)))))) (cond - ((string-match "^\\(\\*+\\)[ \t]+\\(.*\\)" line) + ((string-match "\\(\\*+\\)\\(?: +\\(.*?\\)\\)?[ \t]*$" line) ;; This is a headline (setq level (org-tr-level (- (match-end 1) (match-beginning 1) level-offset)) diff --git a/lisp/org-exp.el b/lisp/org-exp.el index 9884a31..f0f03b2 100644 --- a/lisp/org-exp.el +++ b/lisp/org-exp.el @@ -1638,7 +1638,8 @@ from the buffer." (defun org-export-protect-quoted-subtrees () "Mark quoted subtrees with the protection property." - (let ((org-re-quote (concat "^\\*+[ \t]+" org-quote-string "\\>"))) + (let ((org-re-quote (format org-heading-keyword-regexp-format + org-quote-string))) (goto-char (point-min)) (while (re-search-forward org-re-quote nil t) (goto-char (match-beginning 0)) @@ -1932,7 +1933,8 @@ table line. If it is a link, add it to the line containing the link." (defun org-export-remove-comment-blocks-and-subtrees () "Remove the comment environment, and also commented subtrees." - (let ((re-commented (concat "^\\*+[ \t]+" org-comment-string "\\>")) + (let ((re-commented (format org-heading-keyword-regexp-format + org-comment-string)) case-fold-search) ;; Remove comment environment (goto-char (point-min)) diff --git a/lisp/org-html.el b/lisp/org-html.el index fde563b..51526a7 100644 --- a/lisp/org-html.el +++ b/lisp/org-html.el @@ -1175,8 +1175,9 @@ PUB-DIR is set, use this as the publishing directory." (plist-get opt-plist :link-home))) (dummy (setq opt-plist (plist-put opt-plist :title title))) (html-table-tag (plist-get opt-plist :html-table-tag)) - (quote-re0 (concat "^[ \t]*" org-quote-string "\\>")) - (quote-re (concat "^\\(\\*+\\)\\([ \t]+" org-quote-string "\\>\\)")) + (quote-re0 (concat "^ *" org-quote-string "\\( +\\|[ \t]*$\\)")) + (quote-re (format org-heading-keyword-regexp-format + org-quote-string)) (inquote nil) (infixed nil) (inverse nil) @@ -1646,7 +1647,7 @@ lang=\"%s\" xml:lang=\"%s\"> t t line)))))) (cond - ((string-match "^\\(\\*+\\)[ \t]+\\(.*\\)" line) + ((string-match "\\(\\*+\\)\\(?: +\\(.*?\\)\\)?[ \t]*$" line) ;; This is a headline (setq level (org-tr-level (- (match-end 1) (match-beginning 1) level-offset)) diff --git a/lisp/org-mouse.el b/lisp/org-mouse.el index 346ba6d..ba625d3 100644 --- a/lisp/org-mouse.el +++ b/lisp/org-mouse.el @@ -631,13 +631,6 @@ This means, between the beginning of line and the point." (set-match-data ',match) (apply ',function rest))))) -(defun org-mouse-match-todo-keyword () - (save-excursion - (org-back-to-heading) - (if (looking-at org-outline-regexp) (goto-char (match-end 0))) - (or (looking-at (concat " +" org-todo-regexp " *")) - (looking-at " \\( *\\)")))) - (defun org-mouse-yank-link (click) (interactive "e") ;; Give temporary modes such as isearch a chance to turn off. diff --git a/lisp/org.el b/lisp/org.el index 945d759..24e35a9 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -4177,6 +4177,10 @@ collapsed state." ;;; Variables for pre-computed regular expressions, all buffer local +(defvar org-heading-regexp nil + "Matches an headline. +Stars are put in group 1 and the trimmed body in group 2.") +(make-variable-buffer-local 'org-heading-regexp) (defvar org-drawer-regexp nil "Matches first line of a hidden block.") (make-variable-buffer-local 'org-drawer-regexp) @@ -4200,22 +4204,28 @@ group 3: Priority cookie group 4: True headline group 5: Tags") (make-variable-buffer-local 'org-complex-heading-regexp) +(defvar org-heading-keyword-regexp-format nil + "Printf format to make regexp to match an headline with some keyword. +This regexp will match the headline of any node which has the +exact keyword that is put into the format. The keyword isn't in +any group by default, but the stars and the body are.") +(make-variable-buffer-local 'org-heading-keyword-regexp-format) +(defvar org-heading-keyword-maybe-regexp-format nil + "Printf format to make regexp to match an headline with some keyword. +This regexp can match any headline with the specified keyword, or +a without a keyword. The keyword isn't in any group by default, +but the stars and the body are.") +(make-variable-buffer-local 'org-heading-keyword-maybe-regexp-format) (defvar org-complex-heading-regexp-format nil "Printf format to make regexp to match an exact headline. -This regexp will match the headline of any node which hase the exact -headline text that is put into the format, but may have any TODO state, -priority and tags.") +This regexp will match the headline of any node which has the +exact headline text that is put into the format, but may have any +TODO state, priority and tags.") (make-variable-buffer-local 'org-complex-heading-regexp-format) (defvar org-todo-line-tags-regexp nil "Matches a headline and puts TODO state into group 2 if present. Also put tags into group 4 if tags are present.") (make-variable-buffer-local 'org-todo-line-tags-regexp) -(defvar org-nl-done-regexp nil - "Matches newline followed by a headline with the DONE keyword.") -(make-variable-buffer-local 'org-nl-done-regexp) -(defvar org-looking-at-done-regexp nil - "Matches the DONE keyword a point.") -(make-variable-buffer-local 'org-looking-at-done-regexp) (defvar org-ds-keyword-length 12 "Maximum length of the Deadline and SCHEDULED keywords.") (make-variable-buffer-local 'org-ds-keyword-length) @@ -4550,7 +4560,9 @@ means to push this value onto the list in the variable.") (assoc (car e) org-tag-alist)) (push e org-tag-alist))))) - ;; Compute the regular expressions and other local variables + ;; Compute the regular expressions and other local variables. + ;; Using `org-outline-regexp-bol' would complicate them much, + ;; because of the fixed white space at the end of that string. (if (not org-done-keywords) (setq org-done-keywords (and org-todo-keywords-1 (list (org-last org-todo-keywords-1))))) @@ -4565,49 +4577,48 @@ means to push this value onto the list in the variable.") org-not-done-keywords (org-delete-all org-done-keywords (copy-sequence org-todo-keywords-1)) org-todo-regexp - (concat "\\<\\(" (mapconcat 'regexp-quote org-todo-keywords-1 - "\\|") "\\)\\>") + (concat "\\(" + (mapconcat 'regexp-quote org-todo-keywords-1 "\\|") + "\\)") org-not-done-regexp - (concat "\\<\\(" + (concat "\\(" (mapconcat 'regexp-quote org-not-done-keywords "\\|") - "\\)\\>") + "\\)") + org-heading-regexp + "\\(\\*+\\)\\(?: +\\(.*?\\)\\)?[ \t]*$" + org-heading-keyword-regexp-format + "\\(\\*+\\)\\(?: +%s\\)\\(?: +\\(.*?\\)\\)?[ \t]*$" + org-heading-keyword-maybe-regexp-format + "\\(\\*+\\)\\(?: +%s\\)?\\(?: +\\(.*?\\)\\)?[ \t]*$" org-not-done-heading-regexp - (concat "^\\(\\*+\\)[ \t]+\\(" - (mapconcat 'regexp-quote org-not-done-keywords "\\|") - "\\)[ \t]+") + (format org-heading-keyword-regexp-format org-not-done-regexp) org-todo-line-regexp - (concat "^\\(\\*+\\)[ \t]+\\(?:\\(" - (mapconcat 'regexp-quote org-todo-keywords-1 "\\|") - "\\)[ \t]+\\)?\\(.*\\)") + (format org-heading-keyword-maybe-regexp-format org-todo-regexp) org-complex-heading-regexp - (concat "^\\(\\*+\\)[ \t]+\\(?:\\(" - (mapconcat 'regexp-quote org-todo-keywords-1 "\\|") - "\\)[ \t]+\\)?" - "\\(?:\\(\\[#.\\]\\)[ \t]+\\)?" - "\\(.*?\\)" - "\\(?:[ \t]+\\(:[[:alnum:]_@#%:]+:\\)\\)?[ \t]*$") + (concat "\\(\\*+\\)" + "\\(?: +" org-todo-regexp "\\)?" + "\\(?: +\\(\\[#.\\]\\)\\)?" + "\\( +:\\(.*?\\)\\)?" + (org-re "\\(?:[ \t]+\\(:[[:alnum:]_@#%:]+:\\)\\)?") + "[ \t]*$") org-complex-heading-regexp-format - (concat "^\\(\\*+\\)[ \t]+\\(?:\\(" - (mapconcat 'regexp-quote org-todo-keywords-1 "\\|") - "\\)[ \t]+\\)?" - "\\(?:\\(\\[#.\\]\\)[ \t]+\\)?" - "\\(?:\\(?:\\[[0-9%%/]+\\]\\)[ \t]+\\)?" ; stats cookie - "\\(%s\\)[ \t]*" - "\\(?:\\[[0-9%%/]+\\]\\)?" ; stats cookie - (org-re "\\(?:[ \t]+\\(:[[:alnum:]_@#%%:]+:\\)\\)?[ \t]*$")) - org-nl-done-regexp - (concat "\n\\*+[ \t]+" - "\\(?:" (mapconcat 'regexp-quote org-done-keywords "\\|") - "\\)" "[ \t]+") + (concat "\\(\\*+\\)" + "\\(?: +" org-todo-regexp "\\)?" + "\\(?: +\\(\\[#.\\]\\)\\)?" + "\\(?: +" + ;; Stats cookies can be sticked to body. + "\\(?:\\[[0-9%%/]+\\] *\\)?" + "\\(%s\\)" + "\\(?: *\\[[0-9%%/]+\\]\\)?" + "\\)" + (org-re "\\(?:[ \t]+\\(:[[:alnum:]_@#%%:]+:\\)\\)?") + "[ \t]*$") org-todo-line-tags-regexp - (concat "^\\(\\*+\\)[ \t]+\\(?:\\(" - (mapconcat 'regexp-quote org-todo-keywords-1 "\\|") - "\\)[ \t]+\\)" - (org-re "\\(.*?\\([ \t]:[[:alnum:]:_@#%]+:[ \t]*\\)?$\\)")) - org-looking-at-done-regexp - (concat "^" "\\(?:" - (mapconcat 'regexp-quote org-done-keywords "\\|") "\\)" - "[ \t]+") + (concat "\\(\\*+\\)" + "\\(?: +" org-todo-regexp "\\)?" + "\\( +\\(.*?\\)\\)?" + (org-re "\\(?:[ \t]+\\(:[[:alnum:]:_@#%]+:\\)\\)?") + "[ \t]*$") org-deadline-regexp (concat "\\<" org-deadline-string) org-deadline-time-regexp (concat "\\<" org-deadline-string " *<\\([^>]+\\)>") @@ -5657,14 +5668,17 @@ needs to be inserted at a specific position in the font-lock sequence.") (if (memq 'footnote lk) '(org-activate-footnote-links)) '("^&?%%(.*\\|<%%([^>\n]*?>" (0 'org-sexp-date t)) '(org-hide-wide-columns (0 nil append)) - ;; TODO lines - (list (concat "^\\*+[ \t]+" org-todo-regexp "\\([ \t]\\|$\\)") - '(1 (org-get-todo-face 1) t)) + ;; TODO keyword + (list (format org-heading-keyword-regexp-format + org-todo-regexp) + '(2 (org-get-todo-face 2) t)) ;; DONE (if org-fontify-done-headline - (list (concat "^[*]+ +\\<\\(" - (mapconcat 'regexp-quote org-done-keywords "\\|") - "\\)\\(.*\\)") + (list (format org-heading-keyword-regexp-format + (concat + "\\(" + (mapconcat 'regexp-quote org-done-keywords "\\|") + "\\)")) '(2 'org-headline-done t)) nil) ;; Priorities @@ -5702,8 +5716,10 @@ needs to be inserted at a specific position in the font-lock sequence.") ;; Code '(org-activate-code (1 'org-code t)) ;; COMMENT - (list (concat "^\\*+[ \t]+\\<\\(" org-comment-string - "\\|" org-quote-string "\\)\\>") + (list (format org-heading-keyword-regexp-format + (concat "\\(" + org-comment-string "\\|" org-quote-string + "\\)")) '(1 'org-special-keyword t)) '("^#.*" (0 'font-lock-comment-face t)) ;; Blocks and meta lines @@ -7027,14 +7043,15 @@ When NO-TODO is non-nil, don't include TODO keywords." (looking-at org-complex-heading-regexp) (match-string 4)) (no-tags - (looking-at "\\*+[ \t]+\\([^\n\r]*?\\)\\([ \t]+:[[:alnum:]:_@#%]+:[ \t]*\\)?$") + (looking-at (concat org-outline-regexp + "\\(.*?\\)" + "\\(?:[ \t]+:[[:alnum:]:_@#%]+:\\)?[ \t]*$")) (match-string 1)) (no-todo - (looking-at (concat "\\*+[ \t]+" org-todo-regexp " +" - "\\([^\n\r]*?[ \t]+:[[:alnum:]:_@#%]+:[ \t]*\\)?$")) - (match-string 2)) - (t (looking-at "\\*+[ \t]+\\([^\r\n]*\\)") - (match-string 1))))) + (looking-at org-todo-line-regexp) + (match-string 3)) + (t (looking-at org-heading-regexp) + (match-string 2))))) (defun org-heading-components () "Return the components of the current heading. @@ -7195,9 +7212,8 @@ in the region." The level is the number of stars at the beginning of the headline." (save-excursion (org-with-limited-levels - (ignore-errors - (org-back-to-heading t) - (funcall outline-level))))) + (if (ignore-errors (org-back-to-heading t)) + (funcall outline-level))))) (defun org-get-previous-line-level () "Return the outline depth of the last headline before the current line. @@ -10962,13 +10978,16 @@ expands them." (save-excursion (org-back-to-heading) (let (case-fold-search) - (if (looking-at (concat org-outline-regexp - "\\( *\\<" org-comment-string "\\>[ \t]*\\)")) - (replace-match "" t t nil 1) - (if (looking-at org-outline-regexp) - (progn - (goto-char (match-end 0)) - (insert org-comment-string " "))))))) + (cond + ((looking-at (format org-heading-keyword-regexp-format + org-comment-string)) + (goto-char (match-end 1)) + (looking-at (concat " +" org-comment-string)) + (replace-match "" t t) + (when (eolp) (insert " "))) + ((looking-at org-outline-regexp) + (goto-char (match-end 0)) + (insert org-comment-string " ")))))) (defvar org-last-todo-state-is-todo nil "This is non-nil when the last TODO state change led to a TODO state. @@ -11050,8 +11069,8 @@ For calling through lisp, arg is also interpreted in the following way: (catch 'exit (org-back-to-heading t) (if (looking-at org-outline-regexp) (goto-char (1- (match-end 0)))) - (or (looking-at (concat " +" org-todo-regexp "\\( +\\|$\\)")) - (looking-at " *")) + (or (looking-at (concat org-todo-regexp "\\( +\\|[ \t]*$\\)")) + (looking-at "\\( *\\|[ \t]*$\\)")) (let* ((match-data (match-data)) (startpos (point-at-bol)) (logging (save-match-data (org-entry-get nil "LOGGING" t t))) @@ -16267,7 +16286,8 @@ When a buffer is unmodified, it is just killed. When modified, it is saved (if (org-on-heading-p t) (add-text-properties (point-at-bol) (org-end-of-subtree t) pa)))) (goto-char (point-min)) - (setq re (concat org-outline-regexp-bol "+" org-comment-string "\\>")) + (setq re (format org-heading-keyword-regexp-format + org-comment-string)) (while (re-search-forward re nil t) (add-text-properties (match-beginning 0) (org-end-of-subtree t) pc))) @@ -19818,13 +19838,16 @@ this line is also exported in fixed-width font." (forward-line 1))) (save-excursion (org-back-to-heading) - (if (looking-at (concat org-outline-regexp - "\\( *\\<" org-quote-string "\\>[ \t]*\\)")) - (replace-match "" t t nil 1) - (if (looking-at org-outline-regexp) - (progn - (goto-char (match-end 0)) - (insert org-quote-string " ")))))))) + (cond + ((looking-at (format org-heading-keyword-regexp-format + org-quote-string)) + (goto-char (match-end 1)) + (looking-at (concat " +" org-quote-string)) + (replace-match "" t t) + (when (eolp) (insert " "))) + ((looking-at org-outline-regexp) + (goto-char (match-end 0)) + (insert org-quote-string " "))))))) (defun org-reftex-citation () "Use reftex-citation to insert a citation into the buffer. @@ -20140,8 +20163,9 @@ empty." (save-excursion (beginning-of-line 1) (let ((case-fold-search nil)) - (looking-at (concat "^\\(\\*+\\)[ \t]+\\(" org-todo-regexp - "\\)?[ \t]*$")))))) + (looking-at org-todo-line-regexp))) + (string= (match-string 3) ""))) + (defun org-at-heading-or-item-p () (or (org-on-heading-p) (org-at-item-p))) -- 1.7.6.3 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: bug: org-mouse broken 2011-09-22 14:19 ` Nicolas Goaziou @ 2011-09-22 16:26 ` Michael Brand 2011-09-22 18:25 ` Nicolas Goaziou 0 siblings, 1 reply; 17+ messages in thread From: Michael Brand @ 2011-09-22 16:26 UTC (permalink / raw) To: Nicolas Goaziou; +Cc: emacs-orgmode Hi Nicolas The file name 0001-Provide-more-consistent-regexps-for-headlines.patch made me curious and I take the opportunity to support such an effort by testing this patch on release_7.7-316-gdecd722. I found the issue that "* TODO task" setting to done with "C-c C-t d" leads to "* DONE TODO task". Michael ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: bug: org-mouse broken 2011-09-22 16:26 ` Michael Brand @ 2011-09-22 18:25 ` Nicolas Goaziou 2011-09-22 18:45 ` Michael Brand 2011-09-23 10:54 ` Michael Brand 0 siblings, 2 replies; 17+ messages in thread From: Nicolas Goaziou @ 2011-09-22 18:25 UTC (permalink / raw) To: Michael Brand; +Cc: emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 508 bytes --] Hello, Michael Brand <michael.ch.brand@gmail.com> writes: > The file name 0001-Provide-more-consistent-regexps-for-headlines.patch > made me curious and I take the opportunity to support such an effort > by testing this patch on release_7.7-316-gdecd722. Great! Thank you for testing it. > I found the issue that "* TODO task" setting to done with "C-c C-t d" > leads to "* DONE TODO task". Indeed. This is fixed in the following patch. Please disregard the previous one. Regards, -- Nicolas Goaziou [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: patch --] [-- Type: text/x-patch, Size: 24502 bytes --] From 2925d1ee4d8c18c4ef6eba761149fff52d63cbd6 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou <n.goaziou@gmail.com> Date: Thu, 25 Aug 2011 01:58:29 +0200 Subject: [PATCH] Provide more consistent regexps for headlines * lisp/org-agenda.el (org-search-view): Simplify regexp. (org-agenda-get-todos): Use new format string. * lisp/org-archive.el (org-archive-all-done): Simplify regexp. * lisp/org-ascii.el (org-export-as-ascii): More accurate regexp. * lisp/org-colview-xemacs.el (org-columns-capture-view): Use new format string and new string. * lisp/org-colview.el (org-columns-capture-view): Use new format string and new string. * lisp/org-docbook.el (org-export-as-docbook): More accurate regexp. Also use new regexp to match generic headlines. * lisp/org-exp.el (org-export-protect-quoted-subtrees): More accurate regexp. Also use new regexp to match generic headlines. * lisp/org-html.el (org-export-as-html): More accurate regexp. Also use new regexp to match generic headlines. * lisp/org-mouse.el (org-mouse-match-todo-keyword): Removed unused and now erroneous function. * lisp/org.el (org-heading-regexp, org-heading-keyword-regexp-format): New variables. (org-set-regexps-and-options): Create regexps according to the following rule: use spaces only to separate elements from an headline, while allowing mixed tabs and spaces for any indentation job. (org-nl-done-regexp, org-looking-at-done-regexp): Removed variables. (org-set-font-lock-defaults): Fontify again headlines with a keyword and no other text. Use new format strings. (org-get-heading, org-toggle-comment, org-prepare-agenda-buffers, org-toggle-fixed-width-section): Use new format string. (org-todo): More accurate regexps. (org-point-at-end-of-empty-headline): Simplify regexp. (org-insert-heading): Headline can sometimes be nil. This patch attempts to reduce the number of hard-coded headlines, by providing two format strings and one generic string to cover most of the cases of headline construction. --- lisp/org-agenda.el | 35 +++++---- lisp/org-archive.el | 2 +- lisp/org-ascii.el | 4 +- lisp/org-colview-xemacs.el | 5 +- lisp/org-colview.el | 5 +- lisp/org-docbook.el | 7 +- lisp/org-exp.el | 6 +- lisp/org-html.el | 7 +- lisp/org-mouse.el | 7 -- lisp/org.el | 189 +++++++++++++++++++++++++------------------- 10 files changed, 147 insertions(+), 120 deletions(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index b1fa5f5..28c5d44 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -3868,7 +3868,7 @@ in `org-agenda-text-search-extra-files'." (if (not regexps+) (setq regexp org-outline-regexp-bol) (setq regexp (pop regexps+)) - (if hdl-only (setq regexp (concat "^" org-outline-regexp ".*?" + (if hdl-only (setq regexp (concat org-outline-regexp-bol " .*?" regexp)))) (setq files (org-agenda-files nil 'ifmode)) (when (eq (car org-agenda-text-search-extra-files) 'agenda-archives) @@ -4574,18 +4574,21 @@ the documentation of `org-diary'." 'help-echo (format "mouse-2 or RET jump to org file %s" (abbreviate-file-name buffer-file-name)))) - (regexp (concat "^\\*+[ \t]+\\(" - (if org-select-this-todo-keyword - (if (equal org-select-this-todo-keyword "*") - org-todo-regexp - (concat "\\<\\(" - (mapconcat 'identity - (org-split-string - org-select-this-todo-keyword "|") "\\|") - "\\)\\>")) - org-not-done-regexp) - "[^\n\r]*\\)")) - marker priority category category-pos tags todo-state ee txt beg end) + (regexp (format org-heading-keyword-regexp-format + (cond + ((and org-select-this-todo-keyword + (equal org-select-this-todo-keyword "*")) + org-todo-regexp) + (org-select-this-todo-keyword + (concat "\\(" + (mapconcat 'identity + (org-split-string + org-select-this-todo-keyword + "|") + "\\|") "\\)")) + (t org-not-done-regexp)))) + marker priority category tags todo-state + ee txt beg end) (goto-char (point-min)) (while (re-search-forward regexp nil t) (catch :skip @@ -4597,11 +4600,11 @@ the documentation of `org-diary'." (goto-char (1+ beg)) (or org-agenda-todo-list-sublevels (org-end-of-subtree 'invisible)) (throw :skip nil))) - (goto-char (match-beginning 1)) + (goto-char (match-beginning 2)) (setq marker (org-agenda-new-marker (match-beginning 0)) category (org-get-category) category-pos (get-text-property (point) 'org-category-position) - txt (match-string 1) + txt (match-string 2) tags (org-get-tags-at (point)) txt (org-format-agenda-item "" txt category tags) priority (1+ (org-get-priority txt)) @@ -4613,7 +4616,7 @@ the documentation of `org-diary'." 'type "todo" 'todo-state todo-state) (push txt ee) (if org-agenda-todo-list-sublevels - (goto-char (match-end 1)) + (goto-char (match-end 2)) (org-end-of-subtree 'invisible)))) (nreverse ee))) diff --git a/lisp/org-archive.el b/lisp/org-archive.el index 16c35cf..c7a4049 100644 --- a/lisp/org-archive.el +++ b/lisp/org-archive.el @@ -404,7 +404,7 @@ sibling does not exist, it will be created at the end of the subtree." If the cursor is not on a headline, try all level 1 trees. If it is on a headline, try all direct children. When TAG is non-nil, don't move trees, but mark them with the ARCHIVE tag." - (let ((re (concat org-outline-regexp-bol "+" org-not-done-regexp)) re1 + (let ((re org-not-done-heading-regexp) re1 (rea (concat ".*:" org-archive-tag ":")) (begm (make-marker)) (endm (make-marker)) diff --git a/lisp/org-ascii.el b/lisp/org-ascii.el index 056f44b..2663886 100644 --- a/lisp/org-ascii.el +++ b/lisp/org-ascii.el @@ -283,7 +283,7 @@ publishing directory." "UNTITLED")) (email (plist-get opt-plist :email)) (language (plist-get opt-plist :language)) - (quote-re0 (concat "^[ \t]*" org-quote-string "\\>")) + (quote-re0 (concat "^\\(" org-quote-string "\\)\\( +\\|[ \t]*$\\)")) (todo nil) (lang-words nil) (region @@ -406,7 +406,7 @@ publishing directory." txt)) (setq txt (replace-match "" t t txt))) (if (string-match quote-re0 txt) - (setq txt (replace-match "" t t txt))) + (setq txt (replace-match "" t t txt 1))) (if org-export-with-section-numbers (setq txt (concat (org-section-number level) diff --git a/lisp/org-colview-xemacs.el b/lisp/org-colview-xemacs.el index b32e741..a85762f 100644 --- a/lisp/org-colview-xemacs.el +++ b/lisp/org-colview-xemacs.el @@ -1317,12 +1317,13 @@ of fields." (if (featurep 'xemacs) (save-excursion (let* ((title (mapcar 'cadr org-columns-current-fmt-compiled)) - (re-comment (concat "\\*+[ \t]+" org-comment-string "\\>")) + (re-comment (format org-heading-keyword-regexp-format + org-comment-string)) (re-archive (concat ".*:" org-archive-tag ":")) (n (length title)) row tbl) (goto-char (point-min)) - (while (re-search-forward "^\\(\\*+\\) " nil t) + (while (re-search-forward org-heading-regexp nil t) (catch 'next (when (and (or (null maxlevel) (>= maxlevel diff --git a/lisp/org-colview.el b/lisp/org-colview.el index 829a134..0635419 100644 --- a/lisp/org-colview.el +++ b/lisp/org-colview.el @@ -1152,11 +1152,12 @@ containing the title row and all other rows. Each row is a list of fields." (save-excursion (let* ((title (mapcar 'cadr org-columns-current-fmt-compiled)) - (re-comment (concat "\\*+[ \t]+" org-comment-string "\\>")) + (re-comment (format org-heading-keyword-regexp-format + org-comment-string)) (re-archive (concat ".*:" org-archive-tag ":")) (n (length title)) row tbl) (goto-char (point-min)) - (while (re-search-forward "^\\(\\*+\\) " nil t) + (while (re-search-forward org-heading-regexp nil t) (catch 'next (when (and (or (null maxlevel) (>= maxlevel diff --git a/lisp/org-docbook.el b/lisp/org-docbook.el index f09740f..2c997e4 100644 --- a/lisp/org-docbook.el +++ b/lisp/org-docbook.el @@ -498,8 +498,9 @@ publishing directory." ;; We will use HTML table formatter to export tables to DocBook ;; format, so need to set html-table-tag here. (html-table-tag (plist-get opt-plist :html-table-tag)) - (quote-re0 (concat "^[ \t]*" org-quote-string "\\>")) - (quote-re (concat "^\\(\\*+\\)\\([ \t]+" org-quote-string "\\>\\)")) + (quote-re0 (concat "^ *" org-quote-string "\\( +\\|[ \t]*$\\)")) + (quote-re (format org-heading-keyword-regexp-format + org-quote-string)) (inquote nil) (infixed nil) (inverse nil) @@ -969,7 +970,7 @@ publishing directory." (push (cons num 1) footref-seen)))))) (cond - ((string-match "^\\(\\*+\\)[ \t]+\\(.*\\)" line) + ((string-match "\\(\\*+\\)\\(?: +\\(.*?\\)\\)?[ \t]*$" line) ;; This is a headline (setq level (org-tr-level (- (match-end 1) (match-beginning 1) level-offset)) diff --git a/lisp/org-exp.el b/lisp/org-exp.el index 9884a31..f0f03b2 100644 --- a/lisp/org-exp.el +++ b/lisp/org-exp.el @@ -1638,7 +1638,8 @@ from the buffer." (defun org-export-protect-quoted-subtrees () "Mark quoted subtrees with the protection property." - (let ((org-re-quote (concat "^\\*+[ \t]+" org-quote-string "\\>"))) + (let ((org-re-quote (format org-heading-keyword-regexp-format + org-quote-string))) (goto-char (point-min)) (while (re-search-forward org-re-quote nil t) (goto-char (match-beginning 0)) @@ -1932,7 +1933,8 @@ table line. If it is a link, add it to the line containing the link." (defun org-export-remove-comment-blocks-and-subtrees () "Remove the comment environment, and also commented subtrees." - (let ((re-commented (concat "^\\*+[ \t]+" org-comment-string "\\>")) + (let ((re-commented (format org-heading-keyword-regexp-format + org-comment-string)) case-fold-search) ;; Remove comment environment (goto-char (point-min)) diff --git a/lisp/org-html.el b/lisp/org-html.el index fde563b..51526a7 100644 --- a/lisp/org-html.el +++ b/lisp/org-html.el @@ -1175,8 +1175,9 @@ PUB-DIR is set, use this as the publishing directory." (plist-get opt-plist :link-home))) (dummy (setq opt-plist (plist-put opt-plist :title title))) (html-table-tag (plist-get opt-plist :html-table-tag)) - (quote-re0 (concat "^[ \t]*" org-quote-string "\\>")) - (quote-re (concat "^\\(\\*+\\)\\([ \t]+" org-quote-string "\\>\\)")) + (quote-re0 (concat "^ *" org-quote-string "\\( +\\|[ \t]*$\\)")) + (quote-re (format org-heading-keyword-regexp-format + org-quote-string)) (inquote nil) (infixed nil) (inverse nil) @@ -1646,7 +1647,7 @@ lang=\"%s\" xml:lang=\"%s\"> t t line)))))) (cond - ((string-match "^\\(\\*+\\)[ \t]+\\(.*\\)" line) + ((string-match "\\(\\*+\\)\\(?: +\\(.*?\\)\\)?[ \t]*$" line) ;; This is a headline (setq level (org-tr-level (- (match-end 1) (match-beginning 1) level-offset)) diff --git a/lisp/org-mouse.el b/lisp/org-mouse.el index 346ba6d..ba625d3 100644 --- a/lisp/org-mouse.el +++ b/lisp/org-mouse.el @@ -631,13 +631,6 @@ This means, between the beginning of line and the point." (set-match-data ',match) (apply ',function rest))))) -(defun org-mouse-match-todo-keyword () - (save-excursion - (org-back-to-heading) - (if (looking-at org-outline-regexp) (goto-char (match-end 0))) - (or (looking-at (concat " +" org-todo-regexp " *")) - (looking-at " \\( *\\)")))) - (defun org-mouse-yank-link (click) (interactive "e") ;; Give temporary modes such as isearch a chance to turn off. diff --git a/lisp/org.el b/lisp/org.el index 945d759..ff94c8a 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -4177,6 +4177,10 @@ collapsed state." ;;; Variables for pre-computed regular expressions, all buffer local +(defvar org-heading-regexp nil + "Matches an headline. +Stars are put in group 1 and the trimmed body in group 2.") +(make-variable-buffer-local 'org-heading-regexp) (defvar org-drawer-regexp nil "Matches first line of a hidden block.") (make-variable-buffer-local 'org-drawer-regexp) @@ -4200,22 +4204,28 @@ group 3: Priority cookie group 4: True headline group 5: Tags") (make-variable-buffer-local 'org-complex-heading-regexp) +(defvar org-heading-keyword-regexp-format nil + "Printf format to make regexp to match an headline with some keyword. +This regexp will match the headline of any node which has the +exact keyword that is put into the format. The keyword isn't in +any group by default, but the stars and the body are.") +(make-variable-buffer-local 'org-heading-keyword-regexp-format) +(defvar org-heading-keyword-maybe-regexp-format nil + "Printf format to make regexp to match an headline with some keyword. +This regexp can match any headline with the specified keyword, or +a without a keyword. The keyword isn't in any group by default, +but the stars and the body are.") +(make-variable-buffer-local 'org-heading-keyword-maybe-regexp-format) (defvar org-complex-heading-regexp-format nil "Printf format to make regexp to match an exact headline. -This regexp will match the headline of any node which hase the exact -headline text that is put into the format, but may have any TODO state, -priority and tags.") +This regexp will match the headline of any node which has the +exact headline text that is put into the format, but may have any +TODO state, priority and tags.") (make-variable-buffer-local 'org-complex-heading-regexp-format) (defvar org-todo-line-tags-regexp nil "Matches a headline and puts TODO state into group 2 if present. Also put tags into group 4 if tags are present.") (make-variable-buffer-local 'org-todo-line-tags-regexp) -(defvar org-nl-done-regexp nil - "Matches newline followed by a headline with the DONE keyword.") -(make-variable-buffer-local 'org-nl-done-regexp) -(defvar org-looking-at-done-regexp nil - "Matches the DONE keyword a point.") -(make-variable-buffer-local 'org-looking-at-done-regexp) (defvar org-ds-keyword-length 12 "Maximum length of the Deadline and SCHEDULED keywords.") (make-variable-buffer-local 'org-ds-keyword-length) @@ -4550,7 +4560,9 @@ means to push this value onto the list in the variable.") (assoc (car e) org-tag-alist)) (push e org-tag-alist))))) - ;; Compute the regular expressions and other local variables + ;; Compute the regular expressions and other local variables. + ;; Using `org-outline-regexp-bol' would complicate them much, + ;; because of the fixed white space at the end of that string. (if (not org-done-keywords) (setq org-done-keywords (and org-todo-keywords-1 (list (org-last org-todo-keywords-1))))) @@ -4565,49 +4577,48 @@ means to push this value onto the list in the variable.") org-not-done-keywords (org-delete-all org-done-keywords (copy-sequence org-todo-keywords-1)) org-todo-regexp - (concat "\\<\\(" (mapconcat 'regexp-quote org-todo-keywords-1 - "\\|") "\\)\\>") + (concat "\\(" + (mapconcat 'regexp-quote org-todo-keywords-1 "\\|") + "\\)") org-not-done-regexp - (concat "\\<\\(" + (concat "\\(" (mapconcat 'regexp-quote org-not-done-keywords "\\|") - "\\)\\>") + "\\)") + org-heading-regexp + "\\(\\*+\\)\\(?: +\\(.*?\\)\\)?[ \t]*$" + org-heading-keyword-regexp-format + "\\(\\*+\\)\\(?: +%s\\)\\(?: +\\(.*?\\)\\)?[ \t]*$" + org-heading-keyword-maybe-regexp-format + "\\(\\*+\\)\\(?: +%s\\)?\\(?: +\\(.*?\\)\\)?[ \t]*$" org-not-done-heading-regexp - (concat "^\\(\\*+\\)[ \t]+\\(" - (mapconcat 'regexp-quote org-not-done-keywords "\\|") - "\\)[ \t]+") + (format org-heading-keyword-regexp-format org-not-done-regexp) org-todo-line-regexp - (concat "^\\(\\*+\\)[ \t]+\\(?:\\(" - (mapconcat 'regexp-quote org-todo-keywords-1 "\\|") - "\\)[ \t]+\\)?\\(.*\\)") + (format org-heading-keyword-maybe-regexp-format org-todo-regexp) org-complex-heading-regexp - (concat "^\\(\\*+\\)[ \t]+\\(?:\\(" - (mapconcat 'regexp-quote org-todo-keywords-1 "\\|") - "\\)[ \t]+\\)?" - "\\(?:\\(\\[#.\\]\\)[ \t]+\\)?" - "\\(.*?\\)" - "\\(?:[ \t]+\\(:[[:alnum:]_@#%:]+:\\)\\)?[ \t]*$") + (concat "\\(\\*+\\)" + "\\(?: +" org-todo-regexp "\\)?" + "\\(?: +\\(\\[#.\\]\\)\\)?" + "\\( +:\\(.*?\\)\\)?" + (org-re "\\(?:[ \t]+\\(:[[:alnum:]_@#%:]+:\\)\\)?") + "[ \t]*$") org-complex-heading-regexp-format - (concat "^\\(\\*+\\)[ \t]+\\(?:\\(" - (mapconcat 'regexp-quote org-todo-keywords-1 "\\|") - "\\)[ \t]+\\)?" - "\\(?:\\(\\[#.\\]\\)[ \t]+\\)?" - "\\(?:\\(?:\\[[0-9%%/]+\\]\\)[ \t]+\\)?" ; stats cookie - "\\(%s\\)[ \t]*" - "\\(?:\\[[0-9%%/]+\\]\\)?" ; stats cookie - (org-re "\\(?:[ \t]+\\(:[[:alnum:]_@#%%:]+:\\)\\)?[ \t]*$")) - org-nl-done-regexp - (concat "\n\\*+[ \t]+" - "\\(?:" (mapconcat 'regexp-quote org-done-keywords "\\|") - "\\)" "[ \t]+") + (concat "\\(\\*+\\)" + "\\(?: +" org-todo-regexp "\\)?" + "\\(?: +\\(\\[#.\\]\\)\\)?" + "\\(?: +" + ;; Stats cookies can be sticked to body. + "\\(?:\\[[0-9%%/]+\\] *\\)?" + "\\(%s\\)" + "\\(?: *\\[[0-9%%/]+\\]\\)?" + "\\)" + (org-re "\\(?:[ \t]+\\(:[[:alnum:]_@#%%:]+:\\)\\)?") + "[ \t]*$") org-todo-line-tags-regexp - (concat "^\\(\\*+\\)[ \t]+\\(?:\\(" - (mapconcat 'regexp-quote org-todo-keywords-1 "\\|") - "\\)[ \t]+\\)" - (org-re "\\(.*?\\([ \t]:[[:alnum:]:_@#%]+:[ \t]*\\)?$\\)")) - org-looking-at-done-regexp - (concat "^" "\\(?:" - (mapconcat 'regexp-quote org-done-keywords "\\|") "\\)" - "[ \t]+") + (concat "\\(\\*+\\)" + "\\(?: +" org-todo-regexp "\\)?" + "\\( +\\(.*?\\)\\)?" + (org-re "\\(?:[ \t]+\\(:[[:alnum:]:_@#%]+:\\)\\)?") + "[ \t]*$") org-deadline-regexp (concat "\\<" org-deadline-string) org-deadline-time-regexp (concat "\\<" org-deadline-string " *<\\([^>]+\\)>") @@ -5657,14 +5668,17 @@ needs to be inserted at a specific position in the font-lock sequence.") (if (memq 'footnote lk) '(org-activate-footnote-links)) '("^&?%%(.*\\|<%%([^>\n]*?>" (0 'org-sexp-date t)) '(org-hide-wide-columns (0 nil append)) - ;; TODO lines - (list (concat "^\\*+[ \t]+" org-todo-regexp "\\([ \t]\\|$\\)") - '(1 (org-get-todo-face 1) t)) + ;; TODO keyword + (list (format org-heading-keyword-regexp-format + org-todo-regexp) + '(2 (org-get-todo-face 2) t)) ;; DONE (if org-fontify-done-headline - (list (concat "^[*]+ +\\<\\(" - (mapconcat 'regexp-quote org-done-keywords "\\|") - "\\)\\(.*\\)") + (list (format org-heading-keyword-regexp-format + (concat + "\\(" + (mapconcat 'regexp-quote org-done-keywords "\\|") + "\\)")) '(2 'org-headline-done t)) nil) ;; Priorities @@ -5702,8 +5716,10 @@ needs to be inserted at a specific position in the font-lock sequence.") ;; Code '(org-activate-code (1 'org-code t)) ;; COMMENT - (list (concat "^\\*+[ \t]+\\<\\(" org-comment-string - "\\|" org-quote-string "\\)\\>") + (list (format org-heading-keyword-regexp-format + (concat "\\(" + org-comment-string "\\|" org-quote-string + "\\)")) '(1 'org-special-keyword t)) '("^#.*" (0 'font-lock-comment-face t)) ;; Blocks and meta lines @@ -6967,6 +6983,7 @@ This is important for non-interactive uses of the command." (let ((p (point))) (goto-char (point-at-bol)) (and (looking-at org-complex-heading-regexp) + (match-beginning 4) (> p (match-beginning 4))))))) tags pos) (cond @@ -7027,14 +7044,15 @@ When NO-TODO is non-nil, don't include TODO keywords." (looking-at org-complex-heading-regexp) (match-string 4)) (no-tags - (looking-at "\\*+[ \t]+\\([^\n\r]*?\\)\\([ \t]+:[[:alnum:]:_@#%]+:[ \t]*\\)?$") + (looking-at (concat org-outline-regexp + "\\(.*?\\)" + "\\(?:[ \t]+:[[:alnum:]:_@#%]+:\\)?[ \t]*$")) (match-string 1)) (no-todo - (looking-at (concat "\\*+[ \t]+" org-todo-regexp " +" - "\\([^\n\r]*?[ \t]+:[[:alnum:]:_@#%]+:[ \t]*\\)?$")) - (match-string 2)) - (t (looking-at "\\*+[ \t]+\\([^\r\n]*\\)") - (match-string 1))))) + (looking-at org-todo-line-regexp) + (match-string 3)) + (t (looking-at org-heading-regexp) + (match-string 2))))) (defun org-heading-components () "Return the components of the current heading. @@ -7195,9 +7213,8 @@ in the region." The level is the number of stars at the beginning of the headline." (save-excursion (org-with-limited-levels - (ignore-errors - (org-back-to-heading t) - (funcall outline-level))))) + (if (ignore-errors (org-back-to-heading t)) + (funcall outline-level))))) (defun org-get-previous-line-level () "Return the outline depth of the last headline before the current line. @@ -10962,13 +10979,16 @@ expands them." (save-excursion (org-back-to-heading) (let (case-fold-search) - (if (looking-at (concat org-outline-regexp - "\\( *\\<" org-comment-string "\\>[ \t]*\\)")) - (replace-match "" t t nil 1) - (if (looking-at org-outline-regexp) - (progn - (goto-char (match-end 0)) - (insert org-comment-string " "))))))) + (cond + ((looking-at (format org-heading-keyword-regexp-format + org-comment-string)) + (goto-char (match-end 1)) + (looking-at (concat " +" org-comment-string)) + (replace-match "" t t) + (when (eolp) (insert " "))) + ((looking-at org-outline-regexp) + (goto-char (match-end 0)) + (insert org-comment-string " ")))))) (defvar org-last-todo-state-is-todo nil "This is non-nil when the last TODO state change led to a TODO state. @@ -11050,8 +11070,8 @@ For calling through lisp, arg is also interpreted in the following way: (catch 'exit (org-back-to-heading t) (if (looking-at org-outline-regexp) (goto-char (1- (match-end 0)))) - (or (looking-at (concat " +" org-todo-regexp "\\( +\\|$\\)")) - (looking-at " *")) + (or (looking-at (concat " +" org-todo-regexp "\\( +\\|[ \t]*$\\)")) + (looking-at "\\( *\\|[ \t]*$\\)")) (let* ((match-data (match-data)) (startpos (point-at-bol)) (logging (save-match-data (org-entry-get nil "LOGGING" t t))) @@ -16267,7 +16287,8 @@ When a buffer is unmodified, it is just killed. When modified, it is saved (if (org-on-heading-p t) (add-text-properties (point-at-bol) (org-end-of-subtree t) pa)))) (goto-char (point-min)) - (setq re (concat org-outline-regexp-bol "+" org-comment-string "\\>")) + (setq re (format org-heading-keyword-regexp-format + org-comment-string)) (while (re-search-forward re nil t) (add-text-properties (match-beginning 0) (org-end-of-subtree t) pc))) @@ -19818,13 +19839,16 @@ this line is also exported in fixed-width font." (forward-line 1))) (save-excursion (org-back-to-heading) - (if (looking-at (concat org-outline-regexp - "\\( *\\<" org-quote-string "\\>[ \t]*\\)")) - (replace-match "" t t nil 1) - (if (looking-at org-outline-regexp) - (progn - (goto-char (match-end 0)) - (insert org-quote-string " ")))))))) + (cond + ((looking-at (format org-heading-keyword-regexp-format + org-quote-string)) + (goto-char (match-end 1)) + (looking-at (concat " +" org-quote-string)) + (replace-match "" t t) + (when (eolp) (insert " "))) + ((looking-at org-outline-regexp) + (goto-char (match-end 0)) + (insert org-quote-string " "))))))) (defun org-reftex-citation () "Use reftex-citation to insert a citation into the buffer. @@ -20140,8 +20164,9 @@ empty." (save-excursion (beginning-of-line 1) (let ((case-fold-search nil)) - (looking-at (concat "^\\(\\*+\\)[ \t]+\\(" org-todo-regexp - "\\)?[ \t]*$")))))) + (looking-at org-todo-line-regexp))) + (string= (match-string 3) ""))) + (defun org-at-heading-or-item-p () (or (org-on-heading-p) (org-at-item-p))) -- 1.7.6.3 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: bug: org-mouse broken 2011-09-22 18:25 ` Nicolas Goaziou @ 2011-09-22 18:45 ` Michael Brand 2011-09-23 10:54 ` Michael Brand 1 sibling, 0 replies; 17+ messages in thread From: Michael Brand @ 2011-09-22 18:45 UTC (permalink / raw) To: Nicolas Goaziou; +Cc: emacs-orgmode On Thu, Sep 22, 2011 at 20:25, Nicolas Goaziou <n.goaziou@gmail.com> wrote: > Indeed. This is fixed in the following patch. Please disregard the > previous one. Works now, thanks. Michael ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: bug: org-mouse broken 2011-09-22 18:25 ` Nicolas Goaziou 2011-09-22 18:45 ` Michael Brand @ 2011-09-23 10:54 ` Michael Brand 2011-09-23 16:45 ` Nicolas Goaziou 1 sibling, 1 reply; 17+ messages in thread From: Michael Brand @ 2011-09-23 10:54 UTC (permalink / raw) To: Nicolas Goaziou; +Cc: emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 1058 bytes --] Hi Nicolas There is an issue with org-feed. The backtrace is attached. I hope this is enough to reproduce: 1) /tmp/feed.org: #+begin_src org ,-*- coding: utf-8-unix -*- ,#+DRAWERS: FEEDSTATUS ,* podcast , :FEEDSTATUS: , :END: #+end_src 2) (setq org-feed-alist '(("podcast" "http://pod.drs.ch/sounds_mpx.xml" "/tmp/feed.org" "podcast"))) 3) (org-feed-update-all) 4) hit SPC once to workaround some non-related org-feed bug (?) that I ignore Michael On Thu, Sep 22, 2011 at 20:25, Nicolas Goaziou <n.goaziou@gmail.com> wrote: > Michael Brand <michael.ch.brand@gmail.com> writes: > >> The file name 0001-Provide-more-consistent-regexps-for-headlines.patch >> made me curious and I take the opportunity to support such an effort >> by testing this patch on release_7.7-316-gdecd722. > > Great! Thank you for testing it. > >> I found the issue that "* TODO task" setting to done with "C-c C-t d" >> leads to "* DONE TODO task". > > Indeed. This is fixed in the following patch. Please disregard the > previous one. [-- Attachment #2: backtrace.txt --] [-- Type: text/plain, Size: 7364 bytes --] Debugger entered--Lisp error: (error "Wrong position") signal(error ("Wrong position")) error("Wrong position") (if (looking-at org-complex-heading-regexp) nil (error "Wrong position")) (unless (looking-at org-complex-heading-regexp) (error "Wrong position")) (save-excursion (goto-char pos) (unless (looking-at org-complex-heading-regexp) (error "Wrong position")) (setq level (org-get-valid-level ... 1)) (org-end-of-subtree t t) (skip-chars-backward " \n") (beginning-of-line 2) (setq pos (point)) (while (setq entry ...) (org-paste-subtree level entry ...)) (org-mark-ring-push pos)) (let (entry level) (save-excursion (goto-char pos) (unless ... ...) (setq level ...) (org-end-of-subtree t t) (skip-chars-backward " \n") (beginning-of-line 2) (setq pos ...) (while ... ...) (org-mark-ring-push pos))) org-feed-add-items(1 ("* Sounds!-Podcast - Vintage-Elektronik: das Apparat Organ Quartet aus Island\n [2011-09-15 Thu 23:55]\n Vier Keyboarder und ein Schlagzeuger bilden zusammen das Apparat Organ Quartet. Die Band aus Island verzichtet auf moderne Computer und Sequencer, verwendet dafür analoge Synthesizer, Farfisa-Orgeln und Casio-Keyboards. Ihr neues Album «Polyfonia» tönt ein wenig nach Kraftwerk, Game-Soundtracks aus den 80er und Prog-Rock aus den 90er-Jahren.\n [[http://pod.drs.ch/mp3/sounds/sounds_201109152355_10193717.mp3]]\n" "* Die belgischen Indie-Rock-Urgesteine mit neuer CD\n [2011-09-19 Mon 23:55]\n dEUS, die belgische Indie-Rock-Institution, feiern in diesem Jahr ihr 20-jähriges Jubiläum. Mit den Alben \"Worst Case Scenario (1994) „In A Bar, Under The Sea\"(1996) und „The Ideal Crash\" (1999) wurden sie auch international zu einer festen Grösse. Übriggeblieben Tom Barman und der Keyboarder Klaas Janzoons. Waren die Vielschichtig und trotzdem geradlinig präsentiert sich die neue, 6.CD „Keep You Close „. Verzichtet wurde auf elektronische Spielereien („Vintage Point\"), Dancefloor-orientierte Beatlastigkeit („The Architect\") oder Zerfahrenheit (\"Pocket Revolution\"). Angesagt ist entspannter Pop-Rock mit Klavier, Gitarre Streicher und Bläser. von der Urbesetzung sind allerdings nur noch der Sänger und Gitarrist Tom Barman und der Keyboarder Klaas Janzoons.\n [[http://pod.drs.ch/mp3/sounds/sounds_201109192355_10194329.mp3]]\n" "* Sounds!-Podcast - Mit Düsi durch die Plattenläden Londons\n [2011-09-20 Tue 23:55]\n Unser Mann in London, Hanspeter Düsi Künzler , stöberte einmal mehr in den Regalen der Plattenläden in der englischen Hauptstadt. Gefunden hat er ein paar heisse, bei uns noch nicht veröffentlichten Herbstneuheiten auf CD und Vinyl. Zu hören sind u.a. Duke Spirit, Veronica Falls, Real Tuesday Weld oder Peggy Sue.\n [[http://pod.drs.ch/mp3/sounds/sounds_201109202355_10194271.mp3]]\n" "* Podcast: Charmanter Folk-Pop vom Duo Slow Club aus Sheffield\n [2011-09-21 Wed 23:55]\n Kennengelernt haben sich Rebeccca Taylor und Charles Watson während der Schulzeit in Sheffield. Seit 2006 machen sie unter dem Name Slow Club gemeinsam Musik. Ihr Debut-Album «Yeah So» war geprägt von einer charmanten Mischung aus Folk und Pop , beschränkt auf Gesang und Gitarre. Auf der neuen CD «Paradise» kommen noch Geige, Piano und E-Gitarre hinzu. Herzschmerz, Liebe und Tod sind die zentralen Themen. \n [[http://pod.drs.ch/mp3/sounds/sounds_201109212355_10194350.mp3]]\n" "* Sounds!-Podcast - Interview mit St. Vincent\n [2011-09-22 Thu 23:55]\n Hinter dem Namen St. Vincent steckt die texanische Singer/Songwriterin und Multiinstrumentalistin Annie Clark. Im Sounds!-Interview spricht sie u.a. über ihre Affinität zu Jazz (John Coltrane, Charlie Mingus), die Bedeutung von Tom Waits oder ihre ersten musikalischen Gehversuche auf dem Computer. Ausserdem verrät sie uns ihre literarischen Vorlieben und gibt Auskunft über die neue CD «Strange Mercy».\n [[http://pod.drs.ch/mp3/sounds/sounds_201109222355_10194051.mp3]]\n")) (progn (if new-handler (progn ... ...) (setq new-formatted ...)) (org-feed-add-items inbox-pos new-formatted)) (if new (progn (if new-handler ... ...) (org-feed-add-items inbox-pos new-formatted))) (when new (if new-handler (progn ... ...) (setq new-formatted ...)) (org-feed-add-items inbox-pos new-formatted)) (save-window-excursion (setq inbox-pos (org-feed-goto-inbox-internal file headline)) (setq old-status (org-feed-read-previous-status inbox-pos drawer)) (setq entries (mapcar ... entries)) (dolist (e entries) (if ... ... ... ...)) (setq new (mapcar parse-entry new) changed (mapcar parse-entry changed)) (when filter (setq new ... changed ...)) (when (not ...) (message "No new items in feed %s" name) (throw ... 0)) (setq guid-alist (append ... ...)) (setq status (mapcar ... entries)) (when new (if new-handler ... ...) (org-feed-add-items inbox-pos new-formatted)) (when (and changed-handler changed) (goto-char inbox-pos) (funcall changed-handler changed)) (org-feed-write-status inbox-pos drawer status) (goto-char inbox-pos) (hide-subtree) (show-children) (org-cycle-hide-drawers (quote children)) (when org-feed-save-after-adding (save-buffer)) (message "Added %d new item%s from feed %s to file %s, heading %s" (length new) (if ... "s" "") name (file-name-nondirectory file) headline) (run-hooks (quote org-feed-after-adding-hook)) (length new)) (save-excursion (save-window-excursion (setq inbox-pos ...) (setq old-status ...) (setq entries ...) (dolist ... ...) (setq new ... changed ...) (when filter ...) (when ... ... ...) (setq guid-alist ...) (setq status ...) (when new ... ...) (when ... ... ...) (org-feed-write-status inbox-pos drawer status) (goto-char inbox-pos) (hide-subtree) (show-children) (org-cycle-hide-drawers ...) (when org-feed-save-after-adding ...) (message "Added %d new item%s from feed %s to file %s, heading %s" ... ... name ... headline) (run-hooks ...) (length new))) (let ((name ...) (url ...) (file ...) (headline ...) (filter ...) (formatter ...) (new-handler ...) (changed-handler ...) (template ...) (drawer ...) (parse-feed ...) (parse-entry ...) feed-buffer inbox-pos new-formatted entries old-status status new changed guid-alist e guid olds) (setq feed-buffer (org-feed-get-feed url)) (unless (and feed-buffer ...) (error "Cannot get feed %s" name)) (when retrieve-only (throw ... feed-buffer)) (setq entries (funcall parse-feed feed-buffer)) (ignore-errors (kill-buffer feed-buffer)) (save-excursion (save-window-excursion ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...))) (catch (quote exit) (let (... ... ... ... ... ... ... ... ... ... ... ... feed-buffer inbox-pos new-formatted entries old-status status new changed guid-alist e guid olds) (setq feed-buffer ...) (unless ... ...) (when retrieve-only ...) (setq entries ...) (ignore-errors ...) (save-excursion ...))) org-feed-update(("podcast" "http://pod.drs.ch/sounds_mpx.xml" "/tmp/feed.org" "podcast")) mapcar(org-feed-update (("podcast" "http://pod.drs.ch/sounds_mpx.xml" "/tmp/feed.org" "podcast"))) (apply (quote +) (mapcar (quote org-feed-update) org-feed-alist)) (let ((nfeeds ...) (nnew ...)) (message "%s from %d %s" (cond ... ... ...) nfeeds (if ... "feed" "feeds"))) org-feed-update-all() eval((org-feed-update-all)) eval-last-sexp-1(nil) eval-last-sexp(nil) call-interactively(eval-last-sexp nil nil) ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: bug: org-mouse broken 2011-09-23 10:54 ` Michael Brand @ 2011-09-23 16:45 ` Nicolas Goaziou 2011-09-23 17:00 ` Michael Brand 2011-09-25 10:19 ` Michael Brand 0 siblings, 2 replies; 17+ messages in thread From: Nicolas Goaziou @ 2011-09-23 16:45 UTC (permalink / raw) To: Michael Brand; +Cc: emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 240 bytes --] Hello, Michael Brand <michael.ch.brand@gmail.com> writes: > There is an issue with org-feed. The backtrace is attached. I hope > this is enough to reproduce. Fixed. Here comes the new patch. Thanks again. Regards, -- Nicolas Goaziou [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: patch --] [-- Type: text/x-patch, Size: 24505 bytes --] From 1f8df0573427f02f0e0553bcfa8bec10ac097188 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou <n.goaziou@gmail.com> Date: Thu, 25 Aug 2011 01:58:29 +0200 Subject: [PATCH] Provide more consistent regexps for headlines * lisp/org-agenda.el (org-search-view): Simplify regexp. (org-agenda-get-todos): Use new format string. * lisp/org-archive.el (org-archive-all-done): Simplify regexp. * lisp/org-ascii.el (org-export-as-ascii): More accurate regexp. * lisp/org-colview-xemacs.el (org-columns-capture-view): Use new format string and new string. * lisp/org-colview.el (org-columns-capture-view): Use new format string and new string. * lisp/org-docbook.el (org-export-as-docbook): More accurate regexp. Also use new regexp to match generic headlines. * lisp/org-exp.el (org-export-protect-quoted-subtrees): More accurate regexp. Also use new regexp to match generic headlines. * lisp/org-html.el (org-export-as-html): More accurate regexp. Also use new regexp to match generic headlines. * lisp/org-mouse.el (org-mouse-match-todo-keyword): Removed unused and now erroneous function. * lisp/org.el (org-heading-regexp, org-heading-keyword-regexp-format): New variables. (org-set-regexps-and-options): Create regexps according to the following rule: use spaces only to separate elements from an headline, while allowing mixed tabs and spaces for any indentation job. (org-nl-done-regexp, org-looking-at-done-regexp): Removed variables. (org-set-font-lock-defaults): Fontify again headlines with a keyword and no other text. Use new format strings. (org-get-heading, org-toggle-comment, org-prepare-agenda-buffers, org-toggle-fixed-width-section): Use new format string. (org-todo): More accurate regexps. (org-point-at-end-of-empty-headline): Simplify regexp. (org-insert-heading): Headline can sometimes be nil. This patch attempts to reduce the number of hard-coded headlines, by providing two format strings and one generic string to cover most of the cases of headline construction. --- lisp/org-agenda.el | 35 +++++---- lisp/org-archive.el | 2 +- lisp/org-ascii.el | 4 +- lisp/org-colview-xemacs.el | 5 +- lisp/org-colview.el | 5 +- lisp/org-docbook.el | 7 +- lisp/org-exp.el | 6 +- lisp/org-html.el | 7 +- lisp/org-mouse.el | 7 -- lisp/org.el | 189 +++++++++++++++++++++++++------------------- 10 files changed, 147 insertions(+), 120 deletions(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index b1fa5f5..28c5d44 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -3868,7 +3868,7 @@ in `org-agenda-text-search-extra-files'." (if (not regexps+) (setq regexp org-outline-regexp-bol) (setq regexp (pop regexps+)) - (if hdl-only (setq regexp (concat "^" org-outline-regexp ".*?" + (if hdl-only (setq regexp (concat org-outline-regexp-bol " .*?" regexp)))) (setq files (org-agenda-files nil 'ifmode)) (when (eq (car org-agenda-text-search-extra-files) 'agenda-archives) @@ -4574,18 +4574,21 @@ the documentation of `org-diary'." 'help-echo (format "mouse-2 or RET jump to org file %s" (abbreviate-file-name buffer-file-name)))) - (regexp (concat "^\\*+[ \t]+\\(" - (if org-select-this-todo-keyword - (if (equal org-select-this-todo-keyword "*") - org-todo-regexp - (concat "\\<\\(" - (mapconcat 'identity - (org-split-string - org-select-this-todo-keyword "|") "\\|") - "\\)\\>")) - org-not-done-regexp) - "[^\n\r]*\\)")) - marker priority category category-pos tags todo-state ee txt beg end) + (regexp (format org-heading-keyword-regexp-format + (cond + ((and org-select-this-todo-keyword + (equal org-select-this-todo-keyword "*")) + org-todo-regexp) + (org-select-this-todo-keyword + (concat "\\(" + (mapconcat 'identity + (org-split-string + org-select-this-todo-keyword + "|") + "\\|") "\\)")) + (t org-not-done-regexp)))) + marker priority category tags todo-state + ee txt beg end) (goto-char (point-min)) (while (re-search-forward regexp nil t) (catch :skip @@ -4597,11 +4600,11 @@ the documentation of `org-diary'." (goto-char (1+ beg)) (or org-agenda-todo-list-sublevels (org-end-of-subtree 'invisible)) (throw :skip nil))) - (goto-char (match-beginning 1)) + (goto-char (match-beginning 2)) (setq marker (org-agenda-new-marker (match-beginning 0)) category (org-get-category) category-pos (get-text-property (point) 'org-category-position) - txt (match-string 1) + txt (match-string 2) tags (org-get-tags-at (point)) txt (org-format-agenda-item "" txt category tags) priority (1+ (org-get-priority txt)) @@ -4613,7 +4616,7 @@ the documentation of `org-diary'." 'type "todo" 'todo-state todo-state) (push txt ee) (if org-agenda-todo-list-sublevels - (goto-char (match-end 1)) + (goto-char (match-end 2)) (org-end-of-subtree 'invisible)))) (nreverse ee))) diff --git a/lisp/org-archive.el b/lisp/org-archive.el index 16c35cf..c7a4049 100644 --- a/lisp/org-archive.el +++ b/lisp/org-archive.el @@ -404,7 +404,7 @@ sibling does not exist, it will be created at the end of the subtree." If the cursor is not on a headline, try all level 1 trees. If it is on a headline, try all direct children. When TAG is non-nil, don't move trees, but mark them with the ARCHIVE tag." - (let ((re (concat org-outline-regexp-bol "+" org-not-done-regexp)) re1 + (let ((re org-not-done-heading-regexp) re1 (rea (concat ".*:" org-archive-tag ":")) (begm (make-marker)) (endm (make-marker)) diff --git a/lisp/org-ascii.el b/lisp/org-ascii.el index 056f44b..2663886 100644 --- a/lisp/org-ascii.el +++ b/lisp/org-ascii.el @@ -283,7 +283,7 @@ publishing directory." "UNTITLED")) (email (plist-get opt-plist :email)) (language (plist-get opt-plist :language)) - (quote-re0 (concat "^[ \t]*" org-quote-string "\\>")) + (quote-re0 (concat "^\\(" org-quote-string "\\)\\( +\\|[ \t]*$\\)")) (todo nil) (lang-words nil) (region @@ -406,7 +406,7 @@ publishing directory." txt)) (setq txt (replace-match "" t t txt))) (if (string-match quote-re0 txt) - (setq txt (replace-match "" t t txt))) + (setq txt (replace-match "" t t txt 1))) (if org-export-with-section-numbers (setq txt (concat (org-section-number level) diff --git a/lisp/org-colview-xemacs.el b/lisp/org-colview-xemacs.el index b32e741..a85762f 100644 --- a/lisp/org-colview-xemacs.el +++ b/lisp/org-colview-xemacs.el @@ -1317,12 +1317,13 @@ of fields." (if (featurep 'xemacs) (save-excursion (let* ((title (mapcar 'cadr org-columns-current-fmt-compiled)) - (re-comment (concat "\\*+[ \t]+" org-comment-string "\\>")) + (re-comment (format org-heading-keyword-regexp-format + org-comment-string)) (re-archive (concat ".*:" org-archive-tag ":")) (n (length title)) row tbl) (goto-char (point-min)) - (while (re-search-forward "^\\(\\*+\\) " nil t) + (while (re-search-forward org-heading-regexp nil t) (catch 'next (when (and (or (null maxlevel) (>= maxlevel diff --git a/lisp/org-colview.el b/lisp/org-colview.el index 829a134..0635419 100644 --- a/lisp/org-colview.el +++ b/lisp/org-colview.el @@ -1152,11 +1152,12 @@ containing the title row and all other rows. Each row is a list of fields." (save-excursion (let* ((title (mapcar 'cadr org-columns-current-fmt-compiled)) - (re-comment (concat "\\*+[ \t]+" org-comment-string "\\>")) + (re-comment (format org-heading-keyword-regexp-format + org-comment-string)) (re-archive (concat ".*:" org-archive-tag ":")) (n (length title)) row tbl) (goto-char (point-min)) - (while (re-search-forward "^\\(\\*+\\) " nil t) + (while (re-search-forward org-heading-regexp nil t) (catch 'next (when (and (or (null maxlevel) (>= maxlevel diff --git a/lisp/org-docbook.el b/lisp/org-docbook.el index f09740f..2c997e4 100644 --- a/lisp/org-docbook.el +++ b/lisp/org-docbook.el @@ -498,8 +498,9 @@ publishing directory." ;; We will use HTML table formatter to export tables to DocBook ;; format, so need to set html-table-tag here. (html-table-tag (plist-get opt-plist :html-table-tag)) - (quote-re0 (concat "^[ \t]*" org-quote-string "\\>")) - (quote-re (concat "^\\(\\*+\\)\\([ \t]+" org-quote-string "\\>\\)")) + (quote-re0 (concat "^ *" org-quote-string "\\( +\\|[ \t]*$\\)")) + (quote-re (format org-heading-keyword-regexp-format + org-quote-string)) (inquote nil) (infixed nil) (inverse nil) @@ -969,7 +970,7 @@ publishing directory." (push (cons num 1) footref-seen)))))) (cond - ((string-match "^\\(\\*+\\)[ \t]+\\(.*\\)" line) + ((string-match "\\(\\*+\\)\\(?: +\\(.*?\\)\\)?[ \t]*$" line) ;; This is a headline (setq level (org-tr-level (- (match-end 1) (match-beginning 1) level-offset)) diff --git a/lisp/org-exp.el b/lisp/org-exp.el index 9884a31..f0f03b2 100644 --- a/lisp/org-exp.el +++ b/lisp/org-exp.el @@ -1638,7 +1638,8 @@ from the buffer." (defun org-export-protect-quoted-subtrees () "Mark quoted subtrees with the protection property." - (let ((org-re-quote (concat "^\\*+[ \t]+" org-quote-string "\\>"))) + (let ((org-re-quote (format org-heading-keyword-regexp-format + org-quote-string))) (goto-char (point-min)) (while (re-search-forward org-re-quote nil t) (goto-char (match-beginning 0)) @@ -1932,7 +1933,8 @@ table line. If it is a link, add it to the line containing the link." (defun org-export-remove-comment-blocks-and-subtrees () "Remove the comment environment, and also commented subtrees." - (let ((re-commented (concat "^\\*+[ \t]+" org-comment-string "\\>")) + (let ((re-commented (format org-heading-keyword-regexp-format + org-comment-string)) case-fold-search) ;; Remove comment environment (goto-char (point-min)) diff --git a/lisp/org-html.el b/lisp/org-html.el index fde563b..51526a7 100644 --- a/lisp/org-html.el +++ b/lisp/org-html.el @@ -1175,8 +1175,9 @@ PUB-DIR is set, use this as the publishing directory." (plist-get opt-plist :link-home))) (dummy (setq opt-plist (plist-put opt-plist :title title))) (html-table-tag (plist-get opt-plist :html-table-tag)) - (quote-re0 (concat "^[ \t]*" org-quote-string "\\>")) - (quote-re (concat "^\\(\\*+\\)\\([ \t]+" org-quote-string "\\>\\)")) + (quote-re0 (concat "^ *" org-quote-string "\\( +\\|[ \t]*$\\)")) + (quote-re (format org-heading-keyword-regexp-format + org-quote-string)) (inquote nil) (infixed nil) (inverse nil) @@ -1646,7 +1647,7 @@ lang=\"%s\" xml:lang=\"%s\"> t t line)))))) (cond - ((string-match "^\\(\\*+\\)[ \t]+\\(.*\\)" line) + ((string-match "\\(\\*+\\)\\(?: +\\(.*?\\)\\)?[ \t]*$" line) ;; This is a headline (setq level (org-tr-level (- (match-end 1) (match-beginning 1) level-offset)) diff --git a/lisp/org-mouse.el b/lisp/org-mouse.el index 346ba6d..ba625d3 100644 --- a/lisp/org-mouse.el +++ b/lisp/org-mouse.el @@ -631,13 +631,6 @@ This means, between the beginning of line and the point." (set-match-data ',match) (apply ',function rest))))) -(defun org-mouse-match-todo-keyword () - (save-excursion - (org-back-to-heading) - (if (looking-at org-outline-regexp) (goto-char (match-end 0))) - (or (looking-at (concat " +" org-todo-regexp " *")) - (looking-at " \\( *\\)")))) - (defun org-mouse-yank-link (click) (interactive "e") ;; Give temporary modes such as isearch a chance to turn off. diff --git a/lisp/org.el b/lisp/org.el index 945d759..de988d6 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -4177,6 +4177,10 @@ collapsed state." ;;; Variables for pre-computed regular expressions, all buffer local +(defvar org-heading-regexp nil + "Matches an headline. +Stars are put in group 1 and the trimmed body in group 2.") +(make-variable-buffer-local 'org-heading-regexp) (defvar org-drawer-regexp nil "Matches first line of a hidden block.") (make-variable-buffer-local 'org-drawer-regexp) @@ -4200,22 +4204,28 @@ group 3: Priority cookie group 4: True headline group 5: Tags") (make-variable-buffer-local 'org-complex-heading-regexp) +(defvar org-heading-keyword-regexp-format nil + "Printf format to make regexp to match an headline with some keyword. +This regexp will match the headline of any node which has the +exact keyword that is put into the format. The keyword isn't in +any group by default, but the stars and the body are.") +(make-variable-buffer-local 'org-heading-keyword-regexp-format) +(defvar org-heading-keyword-maybe-regexp-format nil + "Printf format to make regexp to match an headline with some keyword. +This regexp can match any headline with the specified keyword, or +a without a keyword. The keyword isn't in any group by default, +but the stars and the body are.") +(make-variable-buffer-local 'org-heading-keyword-maybe-regexp-format) (defvar org-complex-heading-regexp-format nil "Printf format to make regexp to match an exact headline. -This regexp will match the headline of any node which hase the exact -headline text that is put into the format, but may have any TODO state, -priority and tags.") +This regexp will match the headline of any node which has the +exact headline text that is put into the format, but may have any +TODO state, priority and tags.") (make-variable-buffer-local 'org-complex-heading-regexp-format) (defvar org-todo-line-tags-regexp nil "Matches a headline and puts TODO state into group 2 if present. Also put tags into group 4 if tags are present.") (make-variable-buffer-local 'org-todo-line-tags-regexp) -(defvar org-nl-done-regexp nil - "Matches newline followed by a headline with the DONE keyword.") -(make-variable-buffer-local 'org-nl-done-regexp) -(defvar org-looking-at-done-regexp nil - "Matches the DONE keyword a point.") -(make-variable-buffer-local 'org-looking-at-done-regexp) (defvar org-ds-keyword-length 12 "Maximum length of the Deadline and SCHEDULED keywords.") (make-variable-buffer-local 'org-ds-keyword-length) @@ -4550,7 +4560,9 @@ means to push this value onto the list in the variable.") (assoc (car e) org-tag-alist)) (push e org-tag-alist))))) - ;; Compute the regular expressions and other local variables + ;; Compute the regular expressions and other local variables. + ;; Using `org-outline-regexp-bol' would complicate them much, + ;; because of the fixed white space at the end of that string. (if (not org-done-keywords) (setq org-done-keywords (and org-todo-keywords-1 (list (org-last org-todo-keywords-1))))) @@ -4565,49 +4577,48 @@ means to push this value onto the list in the variable.") org-not-done-keywords (org-delete-all org-done-keywords (copy-sequence org-todo-keywords-1)) org-todo-regexp - (concat "\\<\\(" (mapconcat 'regexp-quote org-todo-keywords-1 - "\\|") "\\)\\>") + (concat "\\(" + (mapconcat 'regexp-quote org-todo-keywords-1 "\\|") + "\\)") org-not-done-regexp - (concat "\\<\\(" + (concat "\\(" (mapconcat 'regexp-quote org-not-done-keywords "\\|") - "\\)\\>") + "\\)") + org-heading-regexp + "\\(\\*+\\)\\(?: +\\(.*?\\)\\)?[ \t]*$" + org-heading-keyword-regexp-format + "\\(\\*+\\)\\(?: +%s\\)\\(?: +\\(.*?\\)\\)?[ \t]*$" + org-heading-keyword-maybe-regexp-format + "\\(\\*+\\)\\(?: +%s\\)?\\(?: +\\(.*?\\)\\)?[ \t]*$" org-not-done-heading-regexp - (concat "^\\(\\*+\\)[ \t]+\\(" - (mapconcat 'regexp-quote org-not-done-keywords "\\|") - "\\)[ \t]+") + (format org-heading-keyword-regexp-format org-not-done-regexp) org-todo-line-regexp - (concat "^\\(\\*+\\)[ \t]+\\(?:\\(" - (mapconcat 'regexp-quote org-todo-keywords-1 "\\|") - "\\)[ \t]+\\)?\\(.*\\)") + (format org-heading-keyword-maybe-regexp-format org-todo-regexp) org-complex-heading-regexp - (concat "^\\(\\*+\\)[ \t]+\\(?:\\(" - (mapconcat 'regexp-quote org-todo-keywords-1 "\\|") - "\\)[ \t]+\\)?" - "\\(?:\\(\\[#.\\]\\)[ \t]+\\)?" - "\\(.*?\\)" - "\\(?:[ \t]+\\(:[[:alnum:]_@#%:]+:\\)\\)?[ \t]*$") + (concat "\\(\\*+\\)" + "\\(?: +" org-todo-regexp "\\)?" + "\\(?: +\\(\\[#.\\]\\)\\)?" + "\\(?: +\\(.*?\\)\\)?" + (org-re "\\(?:[ \t]+\\(:[[:alnum:]_@#%:]+:\\)\\)?") + "[ \t]*$") org-complex-heading-regexp-format - (concat "^\\(\\*+\\)[ \t]+\\(?:\\(" - (mapconcat 'regexp-quote org-todo-keywords-1 "\\|") - "\\)[ \t]+\\)?" - "\\(?:\\(\\[#.\\]\\)[ \t]+\\)?" - "\\(?:\\(?:\\[[0-9%%/]+\\]\\)[ \t]+\\)?" ; stats cookie - "\\(%s\\)[ \t]*" - "\\(?:\\[[0-9%%/]+\\]\\)?" ; stats cookie - (org-re "\\(?:[ \t]+\\(:[[:alnum:]_@#%%:]+:\\)\\)?[ \t]*$")) - org-nl-done-regexp - (concat "\n\\*+[ \t]+" - "\\(?:" (mapconcat 'regexp-quote org-done-keywords "\\|") - "\\)" "[ \t]+") + (concat "\\(\\*+\\)" + "\\(?: +" org-todo-regexp "\\)?" + "\\(?: +\\(\\[#.\\]\\)\\)?" + "\\(?: +" + ;; Stats cookies can be sticked to body. + "\\(?:\\[[0-9%%/]+\\] *\\)?" + "\\(%s\\)" + "\\(?: *\\[[0-9%%/]+\\]\\)?" + "\\)" + (org-re "\\(?:[ \t]+\\(:[[:alnum:]_@#%%:]+:\\)\\)?") + "[ \t]*$") org-todo-line-tags-regexp - (concat "^\\(\\*+\\)[ \t]+\\(?:\\(" - (mapconcat 'regexp-quote org-todo-keywords-1 "\\|") - "\\)[ \t]+\\)" - (org-re "\\(.*?\\([ \t]:[[:alnum:]:_@#%]+:[ \t]*\\)?$\\)")) - org-looking-at-done-regexp - (concat "^" "\\(?:" - (mapconcat 'regexp-quote org-done-keywords "\\|") "\\)" - "[ \t]+") + (concat "\\(\\*+\\)" + "\\(?: +" org-todo-regexp "\\)?" + "\\(?: +\\(.*?\\)\\)?" + (org-re "\\(?:[ \t]+\\(:[[:alnum:]:_@#%]+:\\)\\)?") + "[ \t]*$") org-deadline-regexp (concat "\\<" org-deadline-string) org-deadline-time-regexp (concat "\\<" org-deadline-string " *<\\([^>]+\\)>") @@ -5657,14 +5668,17 @@ needs to be inserted at a specific position in the font-lock sequence.") (if (memq 'footnote lk) '(org-activate-footnote-links)) '("^&?%%(.*\\|<%%([^>\n]*?>" (0 'org-sexp-date t)) '(org-hide-wide-columns (0 nil append)) - ;; TODO lines - (list (concat "^\\*+[ \t]+" org-todo-regexp "\\([ \t]\\|$\\)") - '(1 (org-get-todo-face 1) t)) + ;; TODO keyword + (list (format org-heading-keyword-regexp-format + org-todo-regexp) + '(2 (org-get-todo-face 2) t)) ;; DONE (if org-fontify-done-headline - (list (concat "^[*]+ +\\<\\(" - (mapconcat 'regexp-quote org-done-keywords "\\|") - "\\)\\(.*\\)") + (list (format org-heading-keyword-regexp-format + (concat + "\\(" + (mapconcat 'regexp-quote org-done-keywords "\\|") + "\\)")) '(2 'org-headline-done t)) nil) ;; Priorities @@ -5702,8 +5716,10 @@ needs to be inserted at a specific position in the font-lock sequence.") ;; Code '(org-activate-code (1 'org-code t)) ;; COMMENT - (list (concat "^\\*+[ \t]+\\<\\(" org-comment-string - "\\|" org-quote-string "\\)\\>") + (list (format org-heading-keyword-regexp-format + (concat "\\(" + org-comment-string "\\|" org-quote-string + "\\)")) '(1 'org-special-keyword t)) '("^#.*" (0 'font-lock-comment-face t)) ;; Blocks and meta lines @@ -6967,6 +6983,7 @@ This is important for non-interactive uses of the command." (let ((p (point))) (goto-char (point-at-bol)) (and (looking-at org-complex-heading-regexp) + (match-beginning 4) (> p (match-beginning 4))))))) tags pos) (cond @@ -7027,14 +7044,15 @@ When NO-TODO is non-nil, don't include TODO keywords." (looking-at org-complex-heading-regexp) (match-string 4)) (no-tags - (looking-at "\\*+[ \t]+\\([^\n\r]*?\\)\\([ \t]+:[[:alnum:]:_@#%]+:[ \t]*\\)?$") + (looking-at (concat org-outline-regexp + "\\(.*?\\)" + "\\(?:[ \t]+:[[:alnum:]:_@#%]+:\\)?[ \t]*$")) (match-string 1)) (no-todo - (looking-at (concat "\\*+[ \t]+" org-todo-regexp " +" - "\\([^\n\r]*?[ \t]+:[[:alnum:]:_@#%]+:[ \t]*\\)?$")) - (match-string 2)) - (t (looking-at "\\*+[ \t]+\\([^\r\n]*\\)") - (match-string 1))))) + (looking-at org-todo-line-regexp) + (match-string 3)) + (t (looking-at org-heading-regexp) + (match-string 2))))) (defun org-heading-components () "Return the components of the current heading. @@ -7195,9 +7213,8 @@ in the region." The level is the number of stars at the beginning of the headline." (save-excursion (org-with-limited-levels - (ignore-errors - (org-back-to-heading t) - (funcall outline-level))))) + (if (ignore-errors (org-back-to-heading t)) + (funcall outline-level))))) (defun org-get-previous-line-level () "Return the outline depth of the last headline before the current line. @@ -10962,13 +10979,16 @@ expands them." (save-excursion (org-back-to-heading) (let (case-fold-search) - (if (looking-at (concat org-outline-regexp - "\\( *\\<" org-comment-string "\\>[ \t]*\\)")) - (replace-match "" t t nil 1) - (if (looking-at org-outline-regexp) - (progn - (goto-char (match-end 0)) - (insert org-comment-string " "))))))) + (cond + ((looking-at (format org-heading-keyword-regexp-format + org-comment-string)) + (goto-char (match-end 1)) + (looking-at (concat " +" org-comment-string)) + (replace-match "" t t) + (when (eolp) (insert " "))) + ((looking-at org-outline-regexp) + (goto-char (match-end 0)) + (insert org-comment-string " ")))))) (defvar org-last-todo-state-is-todo nil "This is non-nil when the last TODO state change led to a TODO state. @@ -11050,8 +11070,8 @@ For calling through lisp, arg is also interpreted in the following way: (catch 'exit (org-back-to-heading t) (if (looking-at org-outline-regexp) (goto-char (1- (match-end 0)))) - (or (looking-at (concat " +" org-todo-regexp "\\( +\\|$\\)")) - (looking-at " *")) + (or (looking-at (concat " +" org-todo-regexp "\\( +\\|[ \t]*$\\)")) + (looking-at "\\( *\\|[ \t]*$\\)")) (let* ((match-data (match-data)) (startpos (point-at-bol)) (logging (save-match-data (org-entry-get nil "LOGGING" t t))) @@ -16267,7 +16287,8 @@ When a buffer is unmodified, it is just killed. When modified, it is saved (if (org-on-heading-p t) (add-text-properties (point-at-bol) (org-end-of-subtree t) pa)))) (goto-char (point-min)) - (setq re (concat org-outline-regexp-bol "+" org-comment-string "\\>")) + (setq re (format org-heading-keyword-regexp-format + org-comment-string)) (while (re-search-forward re nil t) (add-text-properties (match-beginning 0) (org-end-of-subtree t) pc))) @@ -19818,13 +19839,16 @@ this line is also exported in fixed-width font." (forward-line 1))) (save-excursion (org-back-to-heading) - (if (looking-at (concat org-outline-regexp - "\\( *\\<" org-quote-string "\\>[ \t]*\\)")) - (replace-match "" t t nil 1) - (if (looking-at org-outline-regexp) - (progn - (goto-char (match-end 0)) - (insert org-quote-string " ")))))))) + (cond + ((looking-at (format org-heading-keyword-regexp-format + org-quote-string)) + (goto-char (match-end 1)) + (looking-at (concat " +" org-quote-string)) + (replace-match "" t t) + (when (eolp) (insert " "))) + ((looking-at org-outline-regexp) + (goto-char (match-end 0)) + (insert org-quote-string " "))))))) (defun org-reftex-citation () "Use reftex-citation to insert a citation into the buffer. @@ -20140,8 +20164,9 @@ empty." (save-excursion (beginning-of-line 1) (let ((case-fold-search nil)) - (looking-at (concat "^\\(\\*+\\)[ \t]+\\(" org-todo-regexp - "\\)?[ \t]*$")))))) + (looking-at org-todo-line-regexp))) + (string= (match-string 3) ""))) + (defun org-at-heading-or-item-p () (or (org-on-heading-p) (org-at-item-p))) -- 1.7.6.3 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: bug: org-mouse broken 2011-09-23 16:45 ` Nicolas Goaziou @ 2011-09-23 17:00 ` Michael Brand 2011-09-25 10:19 ` Michael Brand 1 sibling, 0 replies; 17+ messages in thread From: Michael Brand @ 2011-09-23 17:00 UTC (permalink / raw) To: Nicolas Goaziou; +Cc: emacs-orgmode Hi Nicolas On Fri, Sep 23, 2011 at 18:45, Nicolas Goaziou <n.goaziou@gmail.com> wrote: > Michael Brand <michael.ch.brand@gmail.com> writes: >> There is an issue with org-feed. The backtrace is attached. I hope >> this is enough to reproduce. > > Fixed. Here comes the new patch. > > Thanks again. I can confirm that the issue is resolved. Thank you. Michael ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: bug: org-mouse broken 2011-09-23 16:45 ` Nicolas Goaziou 2011-09-23 17:00 ` Michael Brand @ 2011-09-25 10:19 ` Michael Brand 2011-09-28 15:53 ` Nicolas Goaziou 1 sibling, 1 reply; 17+ messages in thread From: Michael Brand @ 2011-09-25 10:19 UTC (permalink / raw) To: Nicolas Goaziou; +Cc: emacs-orgmode Hi Nicolas On Fri, Sep 23, 2011 at 18:45, Nicolas Goaziou <n.goaziou@gmail.com> wrote: > Michael Brand <michael.ch.brand@gmail.com> writes: >> There is an issue with org-feed. The backtrace is attached. I hope >> this is enough to reproduce. > > Fixed. Here comes the new patch. > > Thanks again. Only now I stumbled upon an issue with org-shiftleft and org-shiftright which I use rarely. On a heading without any todo keyword and with (setq org-todo-keywords '((sequence "1" "2" "3" "|" "-3" "-2" "-1"))) - C-<left> changes to -2 instead of -1 - C-<right> states the buffer modified but leaves the heading still without any todo keyword instead of 1 After verifying I reapplied the affected patch this time because this issue doesn't bother me much. Michael ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: bug: org-mouse broken 2011-09-25 10:19 ` Michael Brand @ 2011-09-28 15:53 ` Nicolas Goaziou 2011-09-28 16:06 ` Michael Brand 2011-11-03 18:03 ` Michael Brand 0 siblings, 2 replies; 17+ messages in thread From: Nicolas Goaziou @ 2011-09-28 15:53 UTC (permalink / raw) To: Michael Brand; +Cc: emacs-orgmode [-- Attachment #1: Type: text/plain, Size: 504 bytes --] Hello, Michael Brand <michael.ch.brand@gmail.com> writes: > Only now I stumbled upon an issue with org-shiftleft and > org-shiftright which I use rarely. On a heading without any todo > keyword and with > (setq org-todo-keywords '((sequence "1" "2" "3" "|" "-3" "-2" "-1"))) > - C-<left> changes to -2 instead of -1 > - C-<right> states the buffer modified but leaves the heading still > without any todo keyword instead of 1 This should be fixed. Patch follows. Thanks again, -- Nicolas Goaziou [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: patch --] [-- Type: text/x-patch, Size: 24507 bytes --] From 7ff0dba146bfb6b8b21d0150ffb33ccb1aa21a68 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou <n.goaziou@gmail.com> Date: Thu, 25 Aug 2011 01:58:29 +0200 Subject: [PATCH] Provide more consistent regexps for headlines * lisp/org-agenda.el (org-search-view): Simplify regexp. (org-agenda-get-todos): Use new format string. * lisp/org-archive.el (org-archive-all-done): Simplify regexp. * lisp/org-ascii.el (org-export-as-ascii): More accurate regexp. * lisp/org-colview-xemacs.el (org-columns-capture-view): Use new format string and new string. * lisp/org-colview.el (org-columns-capture-view): Use new format string and new string. * lisp/org-docbook.el (org-export-as-docbook): More accurate regexp. Also use new regexp to match generic headlines. * lisp/org-exp.el (org-export-protect-quoted-subtrees): More accurate regexp. Also use new regexp to match generic headlines. * lisp/org-html.el (org-export-as-html): More accurate regexp. Also use new regexp to match generic headlines. * lisp/org-mouse.el (org-mouse-match-todo-keyword): Removed unused and now erroneous function. * lisp/org.el (org-heading-regexp, org-heading-keyword-regexp-format): New variables. (org-set-regexps-and-options): Create regexps according to the following rule: use spaces only to separate elements from an headline, while allowing mixed tabs and spaces for any indentation job. (org-nl-done-regexp, org-looking-at-done-regexp): Removed variables. (org-set-font-lock-defaults): Fontify again headlines with a keyword and no other text. Use new format strings. (org-get-heading, org-toggle-comment, org-prepare-agenda-buffers, org-toggle-fixed-width-section): Use new format string. (org-todo): More accurate regexps. (org-point-at-end-of-empty-headline): Simplify regexp. (org-insert-heading): Headline can sometimes be nil. This patch attempts to reduce the number of hard-coded headlines, by providing two format strings and one generic string to cover most of the cases of headline construction. --- lisp/org-agenda.el | 35 +++++---- lisp/org-archive.el | 2 +- lisp/org-ascii.el | 4 +- lisp/org-colview-xemacs.el | 5 +- lisp/org-colview.el | 5 +- lisp/org-docbook.el | 7 +- lisp/org-exp.el | 6 +- lisp/org-html.el | 7 +- lisp/org-mouse.el | 7 -- lisp/org.el | 189 +++++++++++++++++++++++++------------------- 10 files changed, 147 insertions(+), 120 deletions(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index b1fa5f5..28c5d44 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -3868,7 +3868,7 @@ in `org-agenda-text-search-extra-files'." (if (not regexps+) (setq regexp org-outline-regexp-bol) (setq regexp (pop regexps+)) - (if hdl-only (setq regexp (concat "^" org-outline-regexp ".*?" + (if hdl-only (setq regexp (concat org-outline-regexp-bol " .*?" regexp)))) (setq files (org-agenda-files nil 'ifmode)) (when (eq (car org-agenda-text-search-extra-files) 'agenda-archives) @@ -4574,18 +4574,21 @@ the documentation of `org-diary'." 'help-echo (format "mouse-2 or RET jump to org file %s" (abbreviate-file-name buffer-file-name)))) - (regexp (concat "^\\*+[ \t]+\\(" - (if org-select-this-todo-keyword - (if (equal org-select-this-todo-keyword "*") - org-todo-regexp - (concat "\\<\\(" - (mapconcat 'identity - (org-split-string - org-select-this-todo-keyword "|") "\\|") - "\\)\\>")) - org-not-done-regexp) - "[^\n\r]*\\)")) - marker priority category category-pos tags todo-state ee txt beg end) + (regexp (format org-heading-keyword-regexp-format + (cond + ((and org-select-this-todo-keyword + (equal org-select-this-todo-keyword "*")) + org-todo-regexp) + (org-select-this-todo-keyword + (concat "\\(" + (mapconcat 'identity + (org-split-string + org-select-this-todo-keyword + "|") + "\\|") "\\)")) + (t org-not-done-regexp)))) + marker priority category tags todo-state + ee txt beg end) (goto-char (point-min)) (while (re-search-forward regexp nil t) (catch :skip @@ -4597,11 +4600,11 @@ the documentation of `org-diary'." (goto-char (1+ beg)) (or org-agenda-todo-list-sublevels (org-end-of-subtree 'invisible)) (throw :skip nil))) - (goto-char (match-beginning 1)) + (goto-char (match-beginning 2)) (setq marker (org-agenda-new-marker (match-beginning 0)) category (org-get-category) category-pos (get-text-property (point) 'org-category-position) - txt (match-string 1) + txt (match-string 2) tags (org-get-tags-at (point)) txt (org-format-agenda-item "" txt category tags) priority (1+ (org-get-priority txt)) @@ -4613,7 +4616,7 @@ the documentation of `org-diary'." 'type "todo" 'todo-state todo-state) (push txt ee) (if org-agenda-todo-list-sublevels - (goto-char (match-end 1)) + (goto-char (match-end 2)) (org-end-of-subtree 'invisible)))) (nreverse ee))) diff --git a/lisp/org-archive.el b/lisp/org-archive.el index 16c35cf..c7a4049 100644 --- a/lisp/org-archive.el +++ b/lisp/org-archive.el @@ -404,7 +404,7 @@ sibling does not exist, it will be created at the end of the subtree." If the cursor is not on a headline, try all level 1 trees. If it is on a headline, try all direct children. When TAG is non-nil, don't move trees, but mark them with the ARCHIVE tag." - (let ((re (concat org-outline-regexp-bol "+" org-not-done-regexp)) re1 + (let ((re org-not-done-heading-regexp) re1 (rea (concat ".*:" org-archive-tag ":")) (begm (make-marker)) (endm (make-marker)) diff --git a/lisp/org-ascii.el b/lisp/org-ascii.el index 056f44b..2663886 100644 --- a/lisp/org-ascii.el +++ b/lisp/org-ascii.el @@ -283,7 +283,7 @@ publishing directory." "UNTITLED")) (email (plist-get opt-plist :email)) (language (plist-get opt-plist :language)) - (quote-re0 (concat "^[ \t]*" org-quote-string "\\>")) + (quote-re0 (concat "^\\(" org-quote-string "\\)\\( +\\|[ \t]*$\\)")) (todo nil) (lang-words nil) (region @@ -406,7 +406,7 @@ publishing directory." txt)) (setq txt (replace-match "" t t txt))) (if (string-match quote-re0 txt) - (setq txt (replace-match "" t t txt))) + (setq txt (replace-match "" t t txt 1))) (if org-export-with-section-numbers (setq txt (concat (org-section-number level) diff --git a/lisp/org-colview-xemacs.el b/lisp/org-colview-xemacs.el index b32e741..a85762f 100644 --- a/lisp/org-colview-xemacs.el +++ b/lisp/org-colview-xemacs.el @@ -1317,12 +1317,13 @@ of fields." (if (featurep 'xemacs) (save-excursion (let* ((title (mapcar 'cadr org-columns-current-fmt-compiled)) - (re-comment (concat "\\*+[ \t]+" org-comment-string "\\>")) + (re-comment (format org-heading-keyword-regexp-format + org-comment-string)) (re-archive (concat ".*:" org-archive-tag ":")) (n (length title)) row tbl) (goto-char (point-min)) - (while (re-search-forward "^\\(\\*+\\) " nil t) + (while (re-search-forward org-heading-regexp nil t) (catch 'next (when (and (or (null maxlevel) (>= maxlevel diff --git a/lisp/org-colview.el b/lisp/org-colview.el index 829a134..0635419 100644 --- a/lisp/org-colview.el +++ b/lisp/org-colview.el @@ -1152,11 +1152,12 @@ containing the title row and all other rows. Each row is a list of fields." (save-excursion (let* ((title (mapcar 'cadr org-columns-current-fmt-compiled)) - (re-comment (concat "\\*+[ \t]+" org-comment-string "\\>")) + (re-comment (format org-heading-keyword-regexp-format + org-comment-string)) (re-archive (concat ".*:" org-archive-tag ":")) (n (length title)) row tbl) (goto-char (point-min)) - (while (re-search-forward "^\\(\\*+\\) " nil t) + (while (re-search-forward org-heading-regexp nil t) (catch 'next (when (and (or (null maxlevel) (>= maxlevel diff --git a/lisp/org-docbook.el b/lisp/org-docbook.el index f09740f..2c997e4 100644 --- a/lisp/org-docbook.el +++ b/lisp/org-docbook.el @@ -498,8 +498,9 @@ publishing directory." ;; We will use HTML table formatter to export tables to DocBook ;; format, so need to set html-table-tag here. (html-table-tag (plist-get opt-plist :html-table-tag)) - (quote-re0 (concat "^[ \t]*" org-quote-string "\\>")) - (quote-re (concat "^\\(\\*+\\)\\([ \t]+" org-quote-string "\\>\\)")) + (quote-re0 (concat "^ *" org-quote-string "\\( +\\|[ \t]*$\\)")) + (quote-re (format org-heading-keyword-regexp-format + org-quote-string)) (inquote nil) (infixed nil) (inverse nil) @@ -969,7 +970,7 @@ publishing directory." (push (cons num 1) footref-seen)))))) (cond - ((string-match "^\\(\\*+\\)[ \t]+\\(.*\\)" line) + ((string-match "\\(\\*+\\)\\(?: +\\(.*?\\)\\)?[ \t]*$" line) ;; This is a headline (setq level (org-tr-level (- (match-end 1) (match-beginning 1) level-offset)) diff --git a/lisp/org-exp.el b/lisp/org-exp.el index 9884a31..f0f03b2 100644 --- a/lisp/org-exp.el +++ b/lisp/org-exp.el @@ -1638,7 +1638,8 @@ from the buffer." (defun org-export-protect-quoted-subtrees () "Mark quoted subtrees with the protection property." - (let ((org-re-quote (concat "^\\*+[ \t]+" org-quote-string "\\>"))) + (let ((org-re-quote (format org-heading-keyword-regexp-format + org-quote-string))) (goto-char (point-min)) (while (re-search-forward org-re-quote nil t) (goto-char (match-beginning 0)) @@ -1932,7 +1933,8 @@ table line. If it is a link, add it to the line containing the link." (defun org-export-remove-comment-blocks-and-subtrees () "Remove the comment environment, and also commented subtrees." - (let ((re-commented (concat "^\\*+[ \t]+" org-comment-string "\\>")) + (let ((re-commented (format org-heading-keyword-regexp-format + org-comment-string)) case-fold-search) ;; Remove comment environment (goto-char (point-min)) diff --git a/lisp/org-html.el b/lisp/org-html.el index fde563b..51526a7 100644 --- a/lisp/org-html.el +++ b/lisp/org-html.el @@ -1175,8 +1175,9 @@ PUB-DIR is set, use this as the publishing directory." (plist-get opt-plist :link-home))) (dummy (setq opt-plist (plist-put opt-plist :title title))) (html-table-tag (plist-get opt-plist :html-table-tag)) - (quote-re0 (concat "^[ \t]*" org-quote-string "\\>")) - (quote-re (concat "^\\(\\*+\\)\\([ \t]+" org-quote-string "\\>\\)")) + (quote-re0 (concat "^ *" org-quote-string "\\( +\\|[ \t]*$\\)")) + (quote-re (format org-heading-keyword-regexp-format + org-quote-string)) (inquote nil) (infixed nil) (inverse nil) @@ -1646,7 +1647,7 @@ lang=\"%s\" xml:lang=\"%s\"> t t line)))))) (cond - ((string-match "^\\(\\*+\\)[ \t]+\\(.*\\)" line) + ((string-match "\\(\\*+\\)\\(?: +\\(.*?\\)\\)?[ \t]*$" line) ;; This is a headline (setq level (org-tr-level (- (match-end 1) (match-beginning 1) level-offset)) diff --git a/lisp/org-mouse.el b/lisp/org-mouse.el index 346ba6d..ba625d3 100644 --- a/lisp/org-mouse.el +++ b/lisp/org-mouse.el @@ -631,13 +631,6 @@ This means, between the beginning of line and the point." (set-match-data ',match) (apply ',function rest))))) -(defun org-mouse-match-todo-keyword () - (save-excursion - (org-back-to-heading) - (if (looking-at org-outline-regexp) (goto-char (match-end 0))) - (or (looking-at (concat " +" org-todo-regexp " *")) - (looking-at " \\( *\\)")))) - (defun org-mouse-yank-link (click) (interactive "e") ;; Give temporary modes such as isearch a chance to turn off. diff --git a/lisp/org.el b/lisp/org.el index 5961fde..0f7d71c 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -4177,6 +4177,10 @@ collapsed state." ;;; Variables for pre-computed regular expressions, all buffer local +(defvar org-heading-regexp nil + "Matches an headline. +Stars are put in group 1 and the trimmed body in group 2.") +(make-variable-buffer-local 'org-heading-regexp) (defvar org-drawer-regexp nil "Matches first line of a hidden block.") (make-variable-buffer-local 'org-drawer-regexp) @@ -4200,22 +4204,28 @@ group 3: Priority cookie group 4: True headline group 5: Tags") (make-variable-buffer-local 'org-complex-heading-regexp) +(defvar org-heading-keyword-regexp-format nil + "Printf format to make regexp to match an headline with some keyword. +This regexp will match the headline of any node which has the +exact keyword that is put into the format. The keyword isn't in +any group by default, but the stars and the body are.") +(make-variable-buffer-local 'org-heading-keyword-regexp-format) +(defvar org-heading-keyword-maybe-regexp-format nil + "Printf format to make regexp to match an headline with some keyword. +This regexp can match any headline with the specified keyword, or +a without a keyword. The keyword isn't in any group by default, +but the stars and the body are.") +(make-variable-buffer-local 'org-heading-keyword-maybe-regexp-format) (defvar org-complex-heading-regexp-format nil "Printf format to make regexp to match an exact headline. -This regexp will match the headline of any node which hase the exact -headline text that is put into the format, but may have any TODO state, -priority and tags.") +This regexp will match the headline of any node which has the +exact headline text that is put into the format, but may have any +TODO state, priority and tags.") (make-variable-buffer-local 'org-complex-heading-regexp-format) (defvar org-todo-line-tags-regexp nil "Matches a headline and puts TODO state into group 2 if present. Also put tags into group 4 if tags are present.") (make-variable-buffer-local 'org-todo-line-tags-regexp) -(defvar org-nl-done-regexp nil - "Matches newline followed by a headline with the DONE keyword.") -(make-variable-buffer-local 'org-nl-done-regexp) -(defvar org-looking-at-done-regexp nil - "Matches the DONE keyword a point.") -(make-variable-buffer-local 'org-looking-at-done-regexp) (defvar org-ds-keyword-length 12 "Maximum length of the Deadline and SCHEDULED keywords.") (make-variable-buffer-local 'org-ds-keyword-length) @@ -4550,7 +4560,9 @@ means to push this value onto the list in the variable.") (assoc (car e) org-tag-alist)) (push e org-tag-alist))))) - ;; Compute the regular expressions and other local variables + ;; Compute the regular expressions and other local variables. + ;; Using `org-outline-regexp-bol' would complicate them much, + ;; because of the fixed white space at the end of that string. (if (not org-done-keywords) (setq org-done-keywords (and org-todo-keywords-1 (list (org-last org-todo-keywords-1))))) @@ -4565,49 +4577,48 @@ means to push this value onto the list in the variable.") org-not-done-keywords (org-delete-all org-done-keywords (copy-sequence org-todo-keywords-1)) org-todo-regexp - (concat "\\<\\(" (mapconcat 'regexp-quote org-todo-keywords-1 - "\\|") "\\)\\>") + (concat "\\(" + (mapconcat 'regexp-quote org-todo-keywords-1 "\\|") + "\\)") org-not-done-regexp - (concat "\\<\\(" + (concat "\\(" (mapconcat 'regexp-quote org-not-done-keywords "\\|") - "\\)\\>") + "\\)") + org-heading-regexp + "\\(\\*+\\)\\(?: +\\(.*?\\)\\)?[ \t]*$" + org-heading-keyword-regexp-format + "\\(\\*+\\)\\(?: +%s\\)\\(?: +\\(.*?\\)\\)?[ \t]*$" + org-heading-keyword-maybe-regexp-format + "\\(\\*+\\)\\(?: +%s\\)?\\(?: +\\(.*?\\)\\)?[ \t]*$" org-not-done-heading-regexp - (concat "^\\(\\*+\\)[ \t]+\\(" - (mapconcat 'regexp-quote org-not-done-keywords "\\|") - "\\)[ \t]+") + (format org-heading-keyword-regexp-format org-not-done-regexp) org-todo-line-regexp - (concat "^\\(\\*+\\)[ \t]+\\(?:\\(" - (mapconcat 'regexp-quote org-todo-keywords-1 "\\|") - "\\)[ \t]+\\)?\\(.*\\)") + (format org-heading-keyword-maybe-regexp-format org-todo-regexp) org-complex-heading-regexp - (concat "^\\(\\*+\\)[ \t]+\\(?:\\(" - (mapconcat 'regexp-quote org-todo-keywords-1 "\\|") - "\\)[ \t]+\\)?" - "\\(?:\\(\\[#.\\]\\)[ \t]+\\)?" - "\\(.*?\\)" - "\\(?:[ \t]+\\(:[[:alnum:]_@#%:]+:\\)\\)?[ \t]*$") + (concat "\\(\\*+\\)" + "\\(?: +" org-todo-regexp "\\)?" + "\\(?: +\\(\\[#.\\]\\)\\)?" + "\\(?: +\\(.*?\\)\\)?" + (org-re "\\(?:[ \t]+\\(:[[:alnum:]_@#%:]+:\\)\\)?") + "[ \t]*$") org-complex-heading-regexp-format - (concat "^\\(\\*+\\)[ \t]+\\(?:\\(" - (mapconcat 'regexp-quote org-todo-keywords-1 "\\|") - "\\)[ \t]+\\)?" - "\\(?:\\(\\[#.\\]\\)[ \t]+\\)?" - "\\(?:\\(?:\\[[0-9%%/]+\\]\\)[ \t]+\\)?" ; stats cookie - "\\(%s\\)[ \t]*" - "\\(?:\\[[0-9%%/]+\\]\\)?" ; stats cookie - (org-re "\\(?:[ \t]+\\(:[[:alnum:]_@#%%:]+:\\)\\)?[ \t]*$")) - org-nl-done-regexp - (concat "\n\\*+[ \t]+" - "\\(?:" (mapconcat 'regexp-quote org-done-keywords "\\|") - "\\)" "[ \t]+") + (concat "\\(\\*+\\)" + "\\(?: +" org-todo-regexp "\\)?" + "\\(?: +\\(\\[#.\\]\\)\\)?" + "\\(?: +" + ;; Stats cookies can be sticked to body. + "\\(?:\\[[0-9%%/]+\\] *\\)?" + "\\(%s\\)" + "\\(?: *\\[[0-9%%/]+\\]\\)?" + "\\)" + (org-re "\\(?:[ \t]+\\(:[[:alnum:]_@#%%:]+:\\)\\)?") + "[ \t]*$") org-todo-line-tags-regexp - (concat "^\\(\\*+\\)[ \t]+\\(?:\\(" - (mapconcat 'regexp-quote org-todo-keywords-1 "\\|") - "\\)[ \t]+\\)" - (org-re "\\(.*?\\([ \t]:[[:alnum:]:_@#%]+:[ \t]*\\)?$\\)")) - org-looking-at-done-regexp - (concat "^" "\\(?:" - (mapconcat 'regexp-quote org-done-keywords "\\|") "\\)" - "[ \t]+") + (concat "\\(\\*+\\)" + "\\(?: +" org-todo-regexp "\\)?" + "\\(?: +\\(.*?\\)\\)?" + (org-re "\\(?:[ \t]+\\(:[[:alnum:]:_@#%]+:\\)\\)?") + "[ \t]*$") org-deadline-regexp (concat "\\<" org-deadline-string) org-deadline-time-regexp (concat "\\<" org-deadline-string " *<\\([^>]+\\)>") @@ -5658,14 +5669,17 @@ needs to be inserted at a specific position in the font-lock sequence.") (if (memq 'footnote lk) '(org-activate-footnote-links)) '("^&?%%(.*\\|<%%([^>\n]*?>" (0 'org-sexp-date t)) '(org-hide-wide-columns (0 nil append)) - ;; TODO lines - (list (concat "^\\*+[ \t]+" org-todo-regexp "\\([ \t]\\|$\\)") - '(1 (org-get-todo-face 1) t)) + ;; TODO keyword + (list (format org-heading-keyword-regexp-format + org-todo-regexp) + '(2 (org-get-todo-face 2) t)) ;; DONE (if org-fontify-done-headline - (list (concat "^[*]+ +\\<\\(" - (mapconcat 'regexp-quote org-done-keywords "\\|") - "\\)\\(.*\\)") + (list (format org-heading-keyword-regexp-format + (concat + "\\(" + (mapconcat 'regexp-quote org-done-keywords "\\|") + "\\)")) '(2 'org-headline-done t)) nil) ;; Priorities @@ -5703,8 +5717,10 @@ needs to be inserted at a specific position in the font-lock sequence.") ;; Code '(org-activate-code (1 'org-code t)) ;; COMMENT - (list (concat "^\\*+[ \t]+\\<\\(" org-comment-string - "\\|" org-quote-string "\\)\\>") + (list (format org-heading-keyword-regexp-format + (concat "\\(" + org-comment-string "\\|" org-quote-string + "\\)")) '(1 'org-special-keyword t)) '("^#.*" (0 'font-lock-comment-face t)) ;; Blocks and meta lines @@ -6968,6 +6984,7 @@ This is important for non-interactive uses of the command." (let ((p (point))) (goto-char (point-at-bol)) (and (looking-at org-complex-heading-regexp) + (match-beginning 4) (> p (match-beginning 4))))))) tags pos) (cond @@ -7028,14 +7045,15 @@ When NO-TODO is non-nil, don't include TODO keywords." (looking-at org-complex-heading-regexp) (match-string 4)) (no-tags - (looking-at "\\*+[ \t]+\\([^\n\r]*?\\)\\([ \t]+:[[:alnum:]:_@#%]+:[ \t]*\\)?$") + (looking-at (concat org-outline-regexp + "\\(.*?\\)" + "\\(?:[ \t]+:[[:alnum:]:_@#%]+:\\)?[ \t]*$")) (match-string 1)) (no-todo - (looking-at (concat "\\*+[ \t]+" org-todo-regexp " +" - "\\([^\n\r]*?[ \t]+:[[:alnum:]:_@#%]+:[ \t]*\\)?$")) - (match-string 2)) - (t (looking-at "\\*+[ \t]+\\([^\r\n]*\\)") - (match-string 1))))) + (looking-at org-todo-line-regexp) + (match-string 3)) + (t (looking-at org-heading-regexp) + (match-string 2))))) (defun org-heading-components () "Return the components of the current heading. @@ -7196,9 +7214,8 @@ in the region." The level is the number of stars at the beginning of the headline." (save-excursion (org-with-limited-levels - (ignore-errors - (org-back-to-heading t) - (funcall outline-level))))) + (if (ignore-errors (org-back-to-heading t)) + (funcall outline-level))))) (defun org-get-previous-line-level () "Return the outline depth of the last headline before the current line. @@ -10963,13 +10980,16 @@ expands them." (save-excursion (org-back-to-heading) (let (case-fold-search) - (if (looking-at (concat org-outline-regexp - "\\( *\\<" org-comment-string "\\>[ \t]*\\)")) - (replace-match "" t t nil 1) - (if (looking-at org-outline-regexp) - (progn - (goto-char (match-end 0)) - (insert org-comment-string " "))))))) + (cond + ((looking-at (format org-heading-keyword-regexp-format + org-comment-string)) + (goto-char (match-end 1)) + (looking-at (concat " +" org-comment-string)) + (replace-match "" t t) + (when (eolp) (insert " "))) + ((looking-at org-outline-regexp) + (goto-char (match-end 0)) + (insert org-comment-string " ")))))) (defvar org-last-todo-state-is-todo nil "This is non-nil when the last TODO state change led to a TODO state. @@ -11051,8 +11071,8 @@ For calling through lisp, arg is also interpreted in the following way: (catch 'exit (org-back-to-heading t) (if (looking-at org-outline-regexp) (goto-char (1- (match-end 0)))) - (or (looking-at (concat " +" org-todo-regexp "\\( +\\|$\\)")) - (looking-at " *")) + (or (looking-at (concat " +" org-todo-regexp "\\( +\\|[ \t]*$\\)")) + (looking-at "\\(?: *\\|[ \t]*$\\)")) (let* ((match-data (match-data)) (startpos (point-at-bol)) (logging (save-match-data (org-entry-get nil "LOGGING" t t))) @@ -16268,7 +16288,8 @@ When a buffer is unmodified, it is just killed. When modified, it is saved (if (org-on-heading-p t) (add-text-properties (point-at-bol) (org-end-of-subtree t) pa)))) (goto-char (point-min)) - (setq re (concat org-outline-regexp-bol "+" org-comment-string "\\>")) + (setq re (format org-heading-keyword-regexp-format + org-comment-string)) (while (re-search-forward re nil t) (add-text-properties (match-beginning 0) (org-end-of-subtree t) pc))) @@ -19819,13 +19840,16 @@ this line is also exported in fixed-width font." (forward-line 1))) (save-excursion (org-back-to-heading) - (if (looking-at (concat org-outline-regexp - "\\( *\\<" org-quote-string "\\>[ \t]*\\)")) - (replace-match "" t t nil 1) - (if (looking-at org-outline-regexp) - (progn - (goto-char (match-end 0)) - (insert org-quote-string " ")))))))) + (cond + ((looking-at (format org-heading-keyword-regexp-format + org-quote-string)) + (goto-char (match-end 1)) + (looking-at (concat " +" org-quote-string)) + (replace-match "" t t) + (when (eolp) (insert " "))) + ((looking-at org-outline-regexp) + (goto-char (match-end 0)) + (insert org-quote-string " "))))))) (defun org-reftex-citation () "Use reftex-citation to insert a citation into the buffer. @@ -20141,8 +20165,9 @@ empty." (save-excursion (beginning-of-line 1) (let ((case-fold-search nil)) - (looking-at (concat "^\\(\\*+\\)[ \t]+\\(" org-todo-regexp - "\\)?[ \t]*$")))))) + (looking-at org-todo-line-regexp))) + (string= (match-string 3) ""))) + (defun org-at-heading-or-item-p () (or (org-on-heading-p) (org-at-item-p))) -- 1.7.6.4 ^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: bug: org-mouse broken 2011-09-28 15:53 ` Nicolas Goaziou @ 2011-09-28 16:06 ` Michael Brand 2011-11-03 18:03 ` Michael Brand 1 sibling, 0 replies; 17+ messages in thread From: Michael Brand @ 2011-09-28 16:06 UTC (permalink / raw) To: Nicolas Goaziou; +Cc: emacs-orgmode Hi Nicolas On Wed, Sep 28, 2011 at 17:53, Nicolas Goaziou <n.goaziou@gmail.com> wrote: > Hello, > > Michael Brand <michael.ch.brand@gmail.com> writes: > >> Only now I stumbled upon an issue with org-shiftleft and >> org-shiftright which I use rarely. On a heading without any todo >> keyword and with >> (setq org-todo-keywords '((sequence "1" "2" "3" "|" "-3" "-2" "-1"))) >> - C-<left> changes to -2 instead of -1 >> - C-<right> states the buffer modified but leaves the heading still >> without any todo keyword instead of 1 > > This should be fixed. Patch follows. > > Thanks again, I can confirm that the issue is resolved. Thank you. Michael ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: bug: org-mouse broken 2011-09-28 15:53 ` Nicolas Goaziou 2011-09-28 16:06 ` Michael Brand @ 2011-11-03 18:03 ` Michael Brand 2011-11-03 20:43 ` Nicolas Goaziou 1 sibling, 1 reply; 17+ messages in thread From: Michael Brand @ 2011-11-03 18:03 UTC (permalink / raw) To: Nicolas Goaziou; +Cc: emacs-orgmode Hi Nicolas Thanks for applying commit dfcb6faef11a2439b56b18a6289803361d402130 Author: Nicolas Goaziou <n.goaziou@gmail.com> Date: Thu Aug 25 01:58:29 2011 +0200 Provide more consistent regexps for headlines Git bisect finds it as the reason of a fontification issue of headings with the keyword COMMENT or QUOTE: - the face falls back from org-special-keyword to org-level-<n> - hidestars does not hide any more #+begin_src org ,#+STARTUP: odd showall hidestars ,* section ,*** COMMENT subsection ,*** QUOTE subsection ,*** TODO subsection #+end_src Michael ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: bug: org-mouse broken 2011-11-03 18:03 ` Michael Brand @ 2011-11-03 20:43 ` Nicolas Goaziou 2011-11-03 21:10 ` Michael Brand 0 siblings, 1 reply; 17+ messages in thread From: Nicolas Goaziou @ 2011-11-03 20:43 UTC (permalink / raw) To: Michael Brand; +Cc: emacs-orgmode Hello, Michael Brand <michael.ch.brand@gmail.com> writes: > Git bisect finds it as the reason of a fontification issue of > headings with the keyword COMMENT or QUOTE: > - the face falls back from org-special-keyword to org-level-<n> > - hidestars does not hide any more > > #+begin_src org > ,#+STARTUP: odd showall hidestars > ,* section > ,*** COMMENT subsection > ,*** QUOTE subsection > ,*** TODO subsection > #+end_src I have pushed a fix in master. Thanks for reporting this. Regards, -- Nicolas Goaziou ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: bug: org-mouse broken 2011-11-03 20:43 ` Nicolas Goaziou @ 2011-11-03 21:10 ` Michael Brand 0 siblings, 0 replies; 17+ messages in thread From: Michael Brand @ 2011-11-03 21:10 UTC (permalink / raw) To: Nicolas Goaziou; +Cc: emacs-orgmode Hi Nicolas On Thu, Nov 3, 2011 at 21:43, Nicolas Goaziou <n.goaziou@gmail.com> wrote: > I have pushed a fix in master. Thanks for reporting this. Resolved, thanks. Michael ^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2011-11-03 21:11 UTC | newest] Thread overview: 17+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2011-08-19 5:56 bug: org-mouse broken Samuel Wales 2011-08-19 6:06 ` Samuel Wales 2011-09-20 17:39 ` Samuel Wales 2011-09-20 17:42 ` Samuel Wales 2011-09-22 14:19 ` Nicolas Goaziou 2011-09-22 16:26 ` Michael Brand 2011-09-22 18:25 ` Nicolas Goaziou 2011-09-22 18:45 ` Michael Brand 2011-09-23 10:54 ` Michael Brand 2011-09-23 16:45 ` Nicolas Goaziou 2011-09-23 17:00 ` Michael Brand 2011-09-25 10:19 ` Michael Brand 2011-09-28 15:53 ` Nicolas Goaziou 2011-09-28 16:06 ` Michael Brand 2011-11-03 18:03 ` Michael Brand 2011-11-03 20:43 ` Nicolas Goaziou 2011-11-03 21:10 ` Michael Brand
Code repositories for project(s) associated with this external index https://git.savannah.gnu.org/cgit/emacs.git https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.