emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@gmail.com>
To: Mikhail Skorzhisnkii <mskorzhinskii@eml.cc>
Cc: Org Mode <emacs-orgmode@gnu.org>
Subject: Re: [PATCH] ox-icalendar.el: customizable vevent summary prefix
Date: Fri, 09 Sep 2022 18:13:52 +0800	[thread overview]
Message-ID: <874jxgety7.fsf@localhost> (raw)
In-Reply-To: <871qslsjv2.fsf@eml.cc>

Mikhail Skorzhisnkii <mskorzhinskii@eml.cc> writes:

> Thank you for suggestion, I seen an announcement about this function, but somehow forgot about it.
>
> Sending next version of these patches. Changes from the next version:

Thanks!

> Subject: [PATCH 3/3] org-refile.el: show refile targets with a title
>
> * lisp/org-refile.el (org-refile-get-targets): Use a document
> title (#+TITLE) instead of file or buffer name in outline path, if
> a corresponding customisation option is set to 'title. Fallback to a
> filename if there is no title in the document.

Please use 2 spaces between sentences in docstrings, comments, and
commit messages. Also, end sentences with ".". See
https://orgmode.org/worg/org-contribute.html#commit-messages and
https://www.gnu.org/software/emacs/manual/html_node/elisp/Documentation-Tips.html

>  (defcustom org-outline-path-complete-in-steps t
>    "Non-nil means complete the outline path in hierarchical steps.
> @@ -319,6 +320,11 @@ converted to a headline before refiling."
>  		 (push (list (and (buffer-file-name (buffer-base-buffer))
>                                    (file-truename (buffer-file-name (buffer-base-buffer))))
>                               f nil nil) tgs))
> +               (when (eq org-refile-use-outline-path 'title)
> +                 (push (list (or (org-get-title)
> +                                 (and f (file-name-nondirectory f)))
> +                             f nil nil)
> +                       tgs))

We have very too many whens in this function. It will be more succinct
to use a single (pcase org-refile-use-outline-path ...) instead.

> +  ;; When `org-refile-use-outline-path' is `title', return extracted
> +  ;; document title
> +  (should
> +   (equal '("T" "T/H1")
> +     (org-test-with-temp-text-in-file "#+title: T\n* H1"

You may as well add a test when multiple #+title lines are present.

> From 62684b478ae5ceb03f66967fbebcc4d6163c826c Mon Sep 17 00:00:00 2001
> From: Mikhail Skorzhinskii <mskorzhinskii@eml.cc>
> Date: Sat, 12 Sep 2020 18:10:05 +0200
> Subject: [PATCH 2/3] org-agenda.el: show document title in outline path
                                     ^Show
> * lisp/org.el (org-display-outline-path): Show a document title (#+TITLE
> value) and an outline path in an echo area if the customisation option
> is set to 'title. Fallback to a file or a buffer name if the document
                  ^  Fallback ;; (double space between sentences)
> title is absent.

>  ** New options
> -*** New custom settings =org-icalendar-scheduled-summary-prefix= and =org-icalendar-deadline-summary-prefix=

This is removing an existing NEWS entry. I guess it is not intentional.

> +*** A new option for custom setting =org-agenda-show-outline-path= to show document title
>  
>  (defcustom org-agenda-show-outline-path t
> -  "Non-nil means show outline path in echo area after line motion."
> +  "Non-nil means show outline path in echo area after line motion.
> +
> +If set to 'title, show outline path with prepended document
> +title.  Fallback to file name is no title is present."
>    :group 'org-agenda-startup
> -  :type 'boolean)
> +  :type '(choice
> +	  (const :tag "Don't show outline path in agenda view." nil)
> +	  (const :tag "Show outline path with prepended file name." t)
> +	  (const :tag "Show outline path with prepended document title. Fallback to file name is no title is present." title)))

I think you can leave
(const :tag "Show outline path with prepended document title." title)

This text will be displayed in drop menu in cutomize interface alongside
with the full docstring. Mentioning the fallback in the docstring should
be good enough.

> From 5b15f886b22dc542220b48ae9659c4c2d56dea78 Mon Sep 17 00:00:00 2001
> From: Mikhail Skorzhinskii <mskorzhinskii@eml.cc>
> Date: Thu, 8 Sep 2022 21:29:23 +0200
> Subject: [PATCH 1/3] org-clock.el: rename org-clock-get-file-title
                                    ^Rename

> * lisp/org.el (org-get-title): A new function to collect a document
> title from an org-mode buffer, based on a org-clock-get-file-title
> implementation.

`org-clock-get-file-title'. Elisp symbols should be quoted.

>  ** New functions and changes in function arguments
> +*** New function ~org-get-title~ to get ~#+TITLE:~ property from buffers

We generally use ~code~ for Elisp symbols and =#+TITLE:= for verbatim
non-code text. (This has not been consistently followed in etc/NEWS, but
at least please change ~#+TITLE~ to =#+TITLE=). See
doc/Documentation_Standards.org

>  ** Removed or renamed functions and variables
> +*** Rename ~org-clock-get-file-title~ to ~org-get-file-title~
> +
> +This function is now part of the =org.el= file.

You do not need to mention this. org-clock-get-file-title was
introduced in recent commits on main. Main is development branch, and we
do not need to document changes on the changes made after the last
release.

>  ;;;###autoload
>  (defun org-dblock-write:clocktable (params)
>    "Write the standard clocktable."
> @@ -2739,7 +2729,7 @@ from the dynamic block definition."
>  			     "\n")
>  
>                       (if filetitle
> -                         (org-clock-get-file-title file-name)
> +                         (org-get-file-title file-name)
>                         (file-name-nondirectory file-name))
>  		     (if level?    "| " "") ;level column, maybe
>  		     (if timestamp "| " "") ;timestamp column, maybe

This may introduce a compiler warning. I suggest running make after
applying your patch and fix possible compiler warnings. (I suspect that
you may need to add declare-function on top of org-clock.el)

> +(defun org-get-file-title (file-name)
> +  "Collect title from `org-mode' FILE-NAME.
> +
> +Return file name if title does not exist."
> +  (or (org-get-title (find-file-noselect file-name))
> +      (file-name-nondirectory file-name)))
> +
> +(defun org-get-title (&optional buffer)
> +  "Collect title from the provided `org-mode' BUFFER.
> +
> +Returns nil if there are no #+TITLE property."
> +  (let ((buffer (or (buffer-base-buffer)
> +                    buffer
> +                    (current-buffer))))
> +    (with-current-buffer buffer
> +      (org-macro-initialize-templates)
> +      (let ((title (assoc-default "title" org-macro-templates)))
> +        (unless (string= "" title)
> +          title)))))

These two functions can be merged into a single `org-get-title' that
accepts buffer or file-name as an optional argument.

-- 
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-09-09 10:14 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-25 15:24 [PATCH] ox-icalendar.el: customizable vevent summary prefix Mikhail Skorzhinskii
2021-12-26 21:26 ` Nicolas Goaziou
2021-12-28 12:10   ` Mikhail Skorzhinskii
2022-07-31  7:16     ` Ihor Radchenko
2022-07-31  7:35       ` Mikhail Skorzhinskiy
2022-07-31 13:02         ` Ihor Radchenko
2022-08-30 13:50           ` Mikhail Skorzhisnkii
2022-08-31 12:09             ` Ihor Radchenko
2022-09-05 18:50               ` Mikhail Skorzhisnkii
2022-09-08  5:40                 ` Ihor Radchenko
2022-09-08 20:10                   ` Mikhail Skorzhisnkii
2022-09-09 10:13                     ` Ihor Radchenko [this message]
2022-10-23 19:15                       ` Mikhail Skorzhisnkii
2022-10-25  6:59                         ` Ihor Radchenko
2022-08-31 12:11             ` Ihor Radchenko
2022-09-01  7:29               ` Bastien
2022-08-31 12:13             ` Ihor Radchenko
2022-09-05 18:59               ` Mikhail Skorzhisnkii
2022-09-05 19:28             ` Mikhail Skorzhisnkii
2022-09-08  5:33               ` Ihor Radchenko

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=874jxgety7.fsf@localhost \
    --to=yantar92@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=mskorzhinskii@eml.cc \
    /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).