From: Matt Price <moptop99@gmail.com>
To: Nicolas Goaziou <mail@nicolasgoaziou.fr>
Cc: Org Mode <emacs-orgmode@gnu.org>
Subject: Re: org-get-heading and COMMENT
Date: Tue, 17 Jan 2017 18:05:13 -0500 [thread overview]
Message-ID: <CAN_Dec9_EADzkumQUVfHNnTc4wG=R5+2p7eiJ6t4CJ3G5b=RBg@mail.gmail.com> (raw)
In-Reply-To: <87inphlx78.fsf@nicolasgoaziou.fr>
[-- Attachment #1.1: Type: text/plain, Size: 584 bytes --]
Sorry for the delay. I am very slow with regexps!
On Sat, Jan 14, 2017 at 6:04 AM, Nicolas Goaziou <mail@nicolasgoaziou.fr>
wrote:
> Hello,
>
> Matt Price <moptop99@gmail.com> writes:
>
> > I see that
> >
> > (org-get-heading t t)
> >
> > executed on a heading like:
> >
> > * COMMENT Heading Title
> >
> > returns:
> >
> > COMMENT Heading Title
> >
> > Should there be a third switch, something like NO-COMMENT?
>
> I have no objection, but it would also need to have NO-PRIORITY for
> completeness. Do you want to provide a patch for that?
>
> Regards,
>
> --
> Nicolas Goaziou
>
[-- Attachment #1.2: Type: text/html, Size: 1127 bytes --]
[-- Attachment #2: 0004-Add-support-for-new-switches-to-org-get-heading.patch --]
[-- Type: text/x-patch, Size: 2763 bytes --]
From 7c78da444b74a7f75645d2af854859a6a7bf476a Mon Sep 17 00:00:00 2001
From: Matt Price <matt.price@utoronto.ca>
Date: Tue, 17 Jan 2017 18:03:12 -0500
Subject: [PATCH 4/4] Add support for new switches to org-get-heading
NO-COMMENT tag, if true, will not return the COMMENT string with
heading.
NO-PRIORITY, if true, will not return the priority string (e.g.,
[#A]).
---
lisp/org.el | 49 +++++++++++++++++++++++++++++--------------------
1 file changed, 29 insertions(+), 20 deletions(-)
diff --git a/lisp/org.el b/lisp/org.el
index cf1581204..349255bf9 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -8015,29 +8015,38 @@ So this will delete or add empty lines."
(insert empty-lines)
(move-to-column column)))
-(defun org-get-heading (&optional no-tags no-todo)
+(defun org-get-heading (&optional no-tags no-todo no-comment no-priority)
"Return the heading of the current entry, without the stars.
-When NO-TAGS is non-nil, don't include tags.
-When NO-TODO is non-nil, don't include TODO keywords."
+ When NO-TAGS is non-nil, don't include tags.
+ When NO-TODO is non-nil, don't include TODO keywords.
+ When NO-COMMENTS is non-nil, don't include comment string.
+ When NO-PRIORITY is non-nil, don't include priority string."
(save-excursion
(org-back-to-heading t)
- (let ((case-fold-search nil))
- (cond
- ((and no-tags no-todo)
- (looking-at org-complex-heading-regexp)
- ;; Return value has to be a string, but match group 4 is
- ;; optional.
- (or (match-string 4) ""))
- (no-tags
- (looking-at (concat org-outline-regexp
- "\\(.*?\\)"
- "\\(?:[ \t]+:[[:alnum:]:_@#%]+:\\)?[ \t]*$"))
- (match-string 1))
- (no-todo
- (looking-at org-todo-line-regexp)
- (match-string 3))
- (t (looking-at org-heading-regexp)
- (match-string 2))))))
+ (looking-at org-complex-heading-regexp)
+ (let* ((case-fold-search nil)
+ (todo (or (match-string 2) nil))
+ (priority (or (match-string 3) nil))
+ (headlineplus (or (match-string 4) nil))
+ (tags (or (match-string 5) nil))
+ (returnval "")
+ )
+ (if (and (not no-todo) todo)
+ (setq returnval (concat todo returnval)))
+ (if (and (not no-priority) priority)
+ (setq returnval (concat returnval (if (> (length returnval) 0) " ") priority
+ )))
+ (if (and no-comment (string= "COMMENT" (substring headlineplus 0 7)))
+ (setq returnval (concat returnval
+ (if (> (length returnval) 0 )
+ " "
+ "")
+ (substring headlineplus 8 nil)))
+ (setq returnval (concat returnval " " headlineplus)))
+ (if (and (not no-tags) tags)
+ (setq returnval (concat returnval " " tags)))
+ returnval
+ )))
(defvar orgstruct-mode) ; defined below
--
2.11.0
next prev parent reply other threads:[~2017-01-17 23:05 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-11 17:10 org-get-heading and COMMENT Matt Price
2017-01-14 11:04 ` Nicolas Goaziou
2017-01-17 23:05 ` Matt Price [this message]
2017-01-18 23:31 ` Nicolas Goaziou
2017-01-19 0:31 ` Matt Price
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAN_Dec9_EADzkumQUVfHNnTc4wG=R5+2p7eiJ6t4CJ3G5b=RBg@mail.gmail.com' \
--to=moptop99@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=mail@nicolasgoaziou.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).