From: Mikhail Skorzhisnkii <mskorzhinskii@eml.cc>
To: Ihor Radchenko <yantar92@gmail.com>
Cc: Org Mode <emacs-orgmode@gnu.org>
Subject: Re: [PATCH] ox-icalendar.el: customizable vevent summary prefix
Date: Mon, 05 Sep 2022 20:59:32 +0200 [thread overview]
Message-ID: <87wnah3asw.fsf@eml.cc> (raw)
In-Reply-To: <87pmggobl9.fsf@localhost>
[-- Attachment #1: Type: text/plain, Size: 344 bytes --]
Ah, sorry — probably forgot to attach it, yes. See the second patch here in the attachment.
Ihor Radchenko <yantar92@gmail.com> writes:
> Mikhail Skorzhisnkii <mskorzhinskii@eml.cc> writes:
>
>> Subject: [PATCH 1/2] org-agenda.el: customize outline path in echo area
>
> I do not see the second patch. Did you forget to attach it?
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0002-org-refile.el-show-refile-targets-with-doc.-title.patch --]
[-- Type: text/x-diff, Size: 6012 bytes --]
From 686a1d813ec8962bff993add1305015eb2788213 Mon Sep 17 00:00:00 2001
From: Mikhail Skorzhinskii <mskorzhinskii@eml.cc>
Date: Mon, 21 Sep 2020 14:53:13 +0200
Subject: [PATCH 2/2] org-refile.el: show refile targets with doc. title
* lisp/org-refile.el (org-refile-use-outline-path): Add new option
'title
* lisp/org-refile.el (org-refile-get-targets): Start refile target
outline with document title (#+TITLE) instead of file name if
corresponding customization is set to 'title. Fallback to filename if
title is absent.
---
etc/ORG-NEWS | 6 ++++++
lisp/org-refile.el | 15 ++++++++++++---
testing/lisp/test-org.el | 37 ++++++++++++++++++++++++++++++++++++-
3 files changed, 54 insertions(+), 4 deletions(-)
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 529fea41a..51471428c 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -290,6 +290,12 @@ level used for top level headings, much like how
headings in HTML export.
** New options
+*** A new option for custom setting =org-refile-use-outline-path= to show document title in refile targets
+
+Setting =org-refile-use-outline-path= to ='title= will show title
+instead of the file name in refile targets. If the documen do not have
+a title, the filename will be used, similar to ='file= option.
+
*** A new option for custom setting =org-agenda-show-outline-path= to show document title
Setting =org-agenda-show-outline-path= to ='title= will show title
diff --git a/lisp/org-refile.el b/lisp/org-refile.el
index 01f0dfa46..88fe13f23 100644
--- a/lisp/org-refile.el
+++ b/lisp/org-refile.el
@@ -158,7 +158,8 @@ When `buffer-name', use the buffer name."
(const :tag "Yes" t)
(const :tag "Start with file name" file)
(const :tag "Start with full file path" full-file-path)
- (const :tag "Start with buffer name" buffer-name)))
+ (const :tag "Start with buffer name" buffer-name)
+ (const :tag "Start with document title" title)))
(defcustom org-outline-path-complete-in-steps t
"Non-nil means complete the outline path in hierarchical steps.
@@ -317,6 +318,9 @@ 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-from-buffer)
+ (and f (file-name-nondirectory f))) f nil nil) tgs))
(org-with-wide-buffer
(goto-char (point-min))
(setq org-outline-path-cache nil)
@@ -343,7 +347,12 @@ converted to a headline before refiling."
(and (buffer-file-name (buffer-base-buffer))
(file-name-nondirectory
(buffer-file-name (buffer-base-buffer))))))
- (`full-file-path
+ (`title (list
+ (or (org-get-title-from-buffer)
+ (and (buffer-file-name (buffer-base-buffer))
+ (file-name-nondirectory
+ (buffer-file-name (buffer-base-buffer)))))))
+ (`full-file-path
(list (buffer-file-name
(buffer-base-buffer))))
(`buffer-name
@@ -631,7 +640,7 @@ this function appends the default value from
(tbl (mapcar
(lambda (x)
(if (and (not (member org-refile-use-outline-path
- '(file full-file-path)))
+ '(file full-file-path title)))
(not (equal filename (nth 1 x))))
(cons (concat (car x) extra " ("
(file-name-nondirectory (nth 1 x)) ")")
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index b14cbeb26..b85dd7dea 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -6728,7 +6728,42 @@ Paragraph<point>"
(org-test-with-temp-text "* H1"
(let* ((org-refile-use-outline-path 'buffer-name)
(org-refile-targets `((nil :level . 1))))
- (member (buffer-name) (mapcar #'car (org-refile-get-targets)))))))
+ (member (buffer-name) (mapcar #'car (org-refile-get-targets))))))
+ ;; 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"
+ (let* ((org-refile-use-outline-path 'title)
+ (org-refile-targets `((nil :level . 1))))
+ (mapcar #'car (org-refile-get-targets))))))
+ ;; When `org-refile-use-outline-path' is `title' validate that
+ ;; deeper levels are correctly reported too (the same behaviour as
+ ;; 'file)
+ (should
+ (equal '("T" "T/H1" "T/H1/H2" "T/H1/H2/H3" "T/H1")
+ (org-test-with-temp-text-in-file "#+title: T\n* H1\n** H2\n*** H3\n* H1"
+ (let ((org-refile-use-outline-path 'title)
+ (org-refile-targets `((nil :maxlevel . 3))))
+ (mapcar #'car (org-refile-get-targets))))))
+ ;; When `org-refile-use-outline-path' is `title' and document do not
+ ;; have an extracted document title, return just the file name
+ (should
+ (org-test-with-temp-text-in-file "* H1"
+ (let* ((filename (buffer-file-name))
+ (org-refile-use-outline-path 'title)
+ (org-refile-targets `((nil :level . 1))))
+ (member (file-name-nondirectory filename)
+ (mapcar #'car (org-refile-get-targets))))))
+ ;; When `org-refile-use-outline-path' is `title' and document is a
+ ;; temporary buffer without a file, it is still possible to extract
+ ;; a title
+ (should
+ (equal '("T" "T/H1")
+ (org-test-with-temp-text "#+title: T\n* H1\n** H2"
+ (let* ((org-refile-use-outline-path 'title)
+ (org-refile-targets `((nil :level . 1))))
+ (mapcar #'car (org-refile-get-targets)))))))
\f
--
2.35.1
next prev parent reply other threads:[~2022-09-05 19:06 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
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 [this message]
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=87wnah3asw.fsf@eml.cc \
--to=mskorzhinskii@eml.cc \
--cc=emacs-orgmode@gnu.org \
--cc=yantar92@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).