emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Patch] Show org file title in org-clock clocktable


From: Ihor Radchenko
Subject: Re: [Patch] Show org file title in org-clock clocktable
Date: Sat, 13 Aug 2022 19:35:22 +0800

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 via email to

[Prev in Thread] Current Thread [Next in Thread]