[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org d4e7bcb4bd 2/4: org-clock.el: Rename org-clock-get-
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org d4e7bcb4bd 2/4: org-clock.el: Rename org-clock-get-file-title |
Date: |
Tue, 25 Oct 2022 02:58:00 -0400 (EDT) |
branch: externals/org
commit d4e7bcb4bd87afbcb08a013111ebc976e3cf3b58
Author: Mikhail Skorzhinskii <mskorzhinskii@eml.cc>
Commit: Ihor Radchenko <yantar92@posteo.net>
org-clock.el: Rename org-clock-get-file-title
* 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.
* lisp/org-clock.el (org-clock-get-file-title): Removed.
---
etc/ORG-NEWS | 4 ++++
lisp/org-clock.el | 13 ++-----------
lisp/org.el | 14 ++++++++++++++
3 files changed, 20 insertions(+), 11 deletions(-)
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index c18c037257..e96aa482b8 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -361,6 +361,10 @@ event time when the alarm time is set to 0. The default
value is
nil -- do not create alarms at the event time.
** New functions and changes in function arguments
+*** New function ~org-get-title~ to get =#+TITLE:= property from buffers
+
+A function to collect the document title from the org-mode buffer.
+
*** ~org-fold-show-entry~ does not fold drawers by default anymore
~org-fold-show-entry~ now accepts an optional argument HIDE-DRAWERS.
diff --git a/lisp/org-clock.el b/lisp/org-clock.el
index 6332399bbb..e98a34f0db 100644
--- a/lisp/org-clock.el
+++ b/lisp/org-clock.el
@@ -2484,16 +2484,6 @@ the currently selected interval size."
(org-update-dblock)
t)))))
-(defun org-clock-get-file-title (file-name)
- "Get the file title from FILE-NAME as a string.
-Return short FILE-NAME if #+title keyword is not found."
- (with-current-buffer (find-file-noselect file-name)
- (org-macro-initialize-templates)
- (let ((title (assoc-default "title" org-macro-templates)))
- (if (null title)
- (file-name-nondirectory file-name)
- title))))
-
;;;###autoload
(defun org-dblock-write:clocktable (params)
"Write the standard clocktable."
@@ -2750,7 +2740,8 @@ from the dynamic block definition."
"\n")
(if filetitle
- (org-clock-get-file-title file-name)
+ (or (org-get-title file-name)
+ (file-name-nondirectory file-name))
(file-name-nondirectory file-name))
(if level? "| " "") ;level column, maybe
(if timestamp "| " "") ;timestamp column, maybe
diff --git a/lisp/org.el b/lisp/org.el
index 8191f08602..f51e6d6d91 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -7423,6 +7423,20 @@ the default is \"/\"."
(setf (substring fpath (- width 2)) "..")))
fpath))
+(defun org-get-title (&optional buffer-or-file)
+ "Collect title from the provided `org-mode' BUFFER-OR-FILE.
+
+Returns nil if there are no #+TITLE property."
+ (let ((buffer (cond ((bufferp buffer-or-file) buffer-or-file)
+ ((stringp buffer-or-file) (find-file-noselect
+ buffer-or-file))
+ (t (current-buffer)))))
+ (with-current-buffer buffer
+ (org-macro-initialize-templates)
+ (let ((title (assoc-default "title" org-macro-templates)))
+ (unless (string= "" title)
+ title)))))
+
(defun org-display-outline-path (&optional file current separator
just-return-string)
"Display the current outline path in the echo area.