emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@gmail.com>
To: Duy Nguyen <ddnguyen2101@gmail.com>
Cc: Emacs-orgmode@gnu.org
Subject: Re: [Patch] Show org file title in org-clock clocktable
Date: Sat, 13 Aug 2022 19:35:22 +0800	[thread overview]
Message-ID: <87tu6g5qbp.fsf@localhost> (raw)
In-Reply-To: <CAM=3T07tcQ4MrC3BDbp_eV-zHy4-3MA5DX0xmeP3-msbgOXXBQ@mail.gmail.com>

Duy Nguyen <ddnguyen2101@gmail.com> writes:

> Not sure how you normally go about updates to submitted patches. For this
> time, I just updated the patch by amending the commit of the previous patch
> I sent. Please let me know another approach is preferable going forward.

This is ok.

Ideally, you can also assign reroll count (version) to the patch and add
something like [PATCH v2] to the subject. But this is optional.

> From 45882f233d961aadbcbc88ee28ba3aac8599296a Mon Sep 17 00:00:00 2001
> From: Duy Nguyen <duynguyen@Duys-MBP.home>
> Date: Fri, 12 Aug 2022 18:40:10 +0200
> Subject: [PATCH] lisp/org-clock.el: Show file title in org-clock clocktable

Thanks for the update! I have some more comments.

> diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
> index 00fe101dc..e9585617e 100644
> --- a/etc/ORG-NEWS
> +++ b/etc/ORG-NEWS
> @@ -270,6 +270,19 @@ example,
>  
>  prints a sub-bibliography containing the book entries with =ai= among
>  their keywords.
> +*** New =:filetitle= option for clock table
> +
> +The =:filetitle= option for clock tables can be set to =t= to show org
> +file title (set by =#+title:=) in the ~File~ column instead of the
> +file name. For example:

We usually use ~code~ for Elisp symbols and code. So, =t= -> ~t~ and
~File~ -> "File". See doc/Documentation_Standards.org

> +#+begin_src org
> +#+BEGIN: clocktable :scope agenda :maxlevel 2 :block thisweek :filetitle t
> +#+end_src

Please, escape #+BEGIN with comma: ,#+BEGIN.
(this is done automatically if you use C-c ' to edit the src block)

> +;;;###autoload
> +(defun org-clock-get-file-title (file-name)
> +  "Get the file title from FILE-NAME as a string. Returns short
> +FILE-NAME if title is not found."
> +  (with-current-buffer (find-file-noselect file-name)
> +    (let ((title (org-collect-keywords '("title"))))
> +      (if (null title)
> +          (file-name-nondirectory file-name)
> +        (nth 1 (assoc "TITLE" title))))))

By convention, we consider a document title to be concatenation of all
the values of #+TITLE keyword inside buffer. That is

#+TITLE: This is
#+TITLE: a title
#+TITLE: written in multiple
#+TITLE: lines

See org-macro--find-keyword-value and org-macro--collect-macros.
You may even make use of the fact that
(assoc "title" org-macro-templates) should give you the document title
without any extra analysis.

-- 
Ihor Radchenko,
Org mode contributor,
Learn more about Org mode at https://orgmode.org/.
Support Org development at https://liberapay.com/org-mode,
or support my work at https://liberapay.com/yantar92


  reply	other threads:[~2022-08-13 11:35 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-12 21:54 [Patch] Show org file title in org-clock clocktable Duy Nguyen
2022-08-13  8:00 ` Ihor Radchenko
2022-08-13 10:55   ` Duy Nguyen
2022-08-13 11:35     ` Ihor Radchenko [this message]
2022-08-15  6:40       ` [PATCH v2] " Duy Nguyen
2022-08-17  9:34         ` Ihor Radchenko
2022-08-17 18:53           ` [PATCH v3] " Duy Nguyen
2022-08-20  6:14             ` Ihor Radchenko
2022-08-21 12:06               ` Duy Nguyen
2022-08-28  8:11                 ` Duy Nguyen
2022-08-28  8:33                   ` Duy Nguyen
2022-08-28 11:30                     ` Duy Nguyen

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=87tu6g5qbp.fsf@localhost \
    --to=yantar92@gmail.com \
    --cc=Emacs-orgmode@gnu.org \
    --cc=ddnguyen2101@gmail.com \
    /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).