[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/denote-menu c9cb089bfa 15/15: added new user option and
From: |
ELPA Syncer |
Subject: |
[elpa] externals/denote-menu c9cb089bfa 15/15: added new user option and unique ids taking file type |
Date: |
Thu, 9 Mar 2023 11:00:08 -0500 (EST) |
branch: externals/denote-menu
commit c9cb089bfaa1375c7d5c6d8b06b0b5a51e9c3037
Author: Mohamed Suliman <sulimanm@tcd.ie>
Commit: Mohamed Suliman <sulimanm@tcd.ie>
added new user option and unique ids taking file type
---
README.org | 4 ++--
denote-menu.el | 49 +++++++++++++++++++++++++++++++++++++++++--------
2 files changed, 43 insertions(+), 10 deletions(-)
diff --git a/README.org b/README.org
index 82ecbfbdab..a04b231766 100644
--- a/README.org
+++ b/README.org
@@ -3,8 +3,6 @@
#+email: sulimanm@tcd.ie
#+language: en
#+options: ':t toc:nil author:t email:t num:t
-#+macro: stable-version 1.0.0
-#+macro: release-date 2022-12-16
* Overview
=denote-menu= provides an interface for viewing your denote files that
@@ -122,6 +120,8 @@ The user options for =denote-menu= are:
- =denote-menu-keywords-column-width= :: A number value for the width
of the keywords column. Defaults to 30. This value is irrelevant as
it is the final column and will take up the remaining width of the buffer.
+- =denote-menu-show-file-type= :: If non-nil, appends the file type of
+ the current denote file to the title.
- =denote-menu-initial-regex= :: A string that is the regular
expression that is used to initially populate the =*Denote*= buffer
with matching entries. This could allow for potential workflows such
diff --git a/denote-menu.el b/denote-menu.el
index f12a7feaf4..daa34d9653 100644
--- a/denote-menu.el
+++ b/denote-menu.el
@@ -75,6 +75,12 @@ denote file corresponding to the button."
:type 'string
:group 'denote-menu)
+
+(defcustom denote-menu-show-file-type t
+ "Whether to show the denote file type"
+ :type 'boolean
+ :group 'denote-menu)
+
(defvar denote-menu-current-regex denote-menu-initial-regex
"The current regex used to match denote filenames.")
@@ -118,15 +124,17 @@ list entry following the defined form. Then updates the
buffer."
(defun denote-menu--entries-to-filenames ()
"Return list of file names present in the *Denote* buffer."
(mapcar (lambda (entry)
- (let ((id (car entry)))
- (file-name-nondirectory (denote-menu-get-path-by-id id))))
+ (let* ((list-entry-identifier (car entry))
+ (list-entry-denote-identifier (car (split-string
list-entry-identifier "-"))))
+ (file-name-nondirectory (denote-menu-get-path-by-id
list-entry-denote-identifier))))
(funcall tabulated-list-entries)))
(defun denote-menu--entries-to-paths ()
"Return list of file paths present in the *Denote* buffer."
(mapcar (lambda (entry)
- (let ((id (car entry)))
- (denote-menu-get-path-by-id id)))
+ (let* ((list-entry-identifier (car entry))
+ (list-entry-denote-identifier (car (split-string
list-entry-identifier "-"))))
+ (denote-menu-get-path-by-id list-entry-denote-identifier)))
(funcall tabulated-list-entries)))
(defun denote-menu-get-path-by-id (id)
@@ -141,14 +149,24 @@ list entry following the defined form. Then updates the
buffer."
"Return list of files matching REGEXP from FILES."
(seq-filter (lambda (f) (string-match-p regexp f)) files))
+(defun denote-menu--path-to-unique-identifier (path)
+ "Convert PATH to a unique identifier to be used for
+`tabulated-list-entries'. Done by taking the denote identifier of
+PATH and appending the filename extension."
+ (let ((path-identifier (denote-retrieve-filename-identifier path))
+ (extension (file-name-extension path)))
+ (format "%s-%s" path-identifier extension)))
+
+
(defun denote-menu--path-to-entry (path)
"Convert PATH to an entry matching the form of `tabulated-list-entries'."
- `(,(denote-retrieve-filename-identifier path)
+ `(,(denote-menu--path-to-unique-identifier path)
[(,(denote-menu-date path) . (action ,(lambda (button) (funcall
denote-menu-action path))))
,(denote-menu-title path)
,(propertize (format "%s" (denote-extract-keywords-from-path path)) 'face
'italic)]))
(defun denote-menu-date (path)
+ "Return human readable date from denote PATH identifier."
(let* ((timestamp (split-string (denote-retrieve-filename-identifier path)
"T"))
(date (car timestamp))
(year (substring date 0 4))
@@ -161,6 +179,11 @@ list entry following the defined form. Then updates the
buffer."
(format "%s-%s-%s %s:%s" year month day hour seconds)))
+
+(defun denote-menu-type (path)
+ "Return file type of PATH"
+ (file-name-extension (file-name-nondirectory path)))
+
(defun denote-menu-title (path)
"Return title of PATH.
If the denote file PATH has no title, return the string \"(No
@@ -170,9 +193,14 @@ Determine whether a denote file has a title based on the
following rule derived from the file naming scheme:
1. If the path does not have a \"--\", it has no title."
- (if (or (not (string-match-p "--" path)))
- (propertize "(No Title)" 'face 'font-lock-comment-face)
- (denote-retrieve-filename-title path)))
+
+ (let* ((title (if (or (not (string-match-p "--" path)))
+ (propertize "(No Title)" 'face 'font-lock-comment-face)
+ (denote-retrieve-filename-title path)))
+ (file-type (propertize (concat "." (denote-menu-type path)) 'face
'font-lock-keyword-face)))
+ (if denote-menu-show-file-type
+ (concat title " " file-type)
+ title)))
(defun denote-menu-filter (regexp)
"Filter `tabulated-list-entries' matching REGEXP.
@@ -183,6 +211,11 @@ Revert the *Denotes* buffer to include only the matching
entries."
(setq denote-menu-current-regex regexp)
(denote-menu-update-entries))
+;; (defun denote-menu-filter-by-type (type)
+;; "Prompt for TYPE and filters the list according to the denote
+;; file extension"
+;; (interactive
+
(defun denote-menu-filter-by-keyword (keywords)
"Prompt for KEYWORDS and filters the list accordingly.
When called from Lisp, KEYWORDS is a list of strings."
- [elpa] externals/denote-menu d8121e610c 09/15: Make 'list-denotes' alias of 'denote-menu-list-notes', (continued)
- [elpa] externals/denote-menu d8121e610c 09/15: Make 'list-denotes' alias of 'denote-menu-list-notes', ELPA Syncer, 2023/03/09
- [elpa] externals/denote-menu f901a2dba5 08/15: fix denote get path by id, ELPA Syncer, 2023/03/09
- [elpa] externals/denote-menu 5bc393e6d2 03/15: README typo, ELPA Syncer, 2023/03/09
- [elpa] externals/denote-menu 8a490728de 10/15: Change tone of doc strings, ELPA Syncer, 2023/03/09
- [elpa] externals/denote-menu f73afbdacb 13/15: fix list-denotes alias and typo in README, ELPA Syncer, 2023/03/09
- [elpa] externals/denote-menu 3bd7cf7d12 01/15: initial commit, ELPA Syncer, 2023/03/09
- [elpa] externals/denote-menu 6a2cde289b 07/15: add denote requirement, ELPA Syncer, 2023/03/09
- [elpa] externals/denote-menu 4a1bbb38f8 11/15: remove all occurences of `denote-get-path-by-id', ELPA Syncer, 2023/03/09
- [elpa] externals/denote-menu b3c33b9fd3 12/15: Merge pull request #1 from protesilaos/master, ELPA Syncer, 2023/03/09
- [elpa] externals/denote-menu ec8349a77a 14/15: added commentary, ELPA Syncer, 2023/03/09
- [elpa] externals/denote-menu c9cb089bfa 15/15: added new user option and unique ids taking file type,
ELPA Syncer <=