emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/xeft 2b1ff8402f 17/55: Various fixes


From: ELPA Syncer
Subject: [elpa] externals/xeft 2b1ff8402f 17/55: Various fixes
Date: Fri, 13 Jan 2023 23:58:37 -0500 (EST)

branch: externals/xeft
commit 2b1ff8402f8f24b6413113a983490f82cee6a173
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>

    Various fixes
    
    * xeft.el (xeft-default-extension): New option.
    (xeft-filename-fn): Use 'xeft-default-extension'.
    (xeft): Create database's path if doesn't exists.
    (xeft-create-note): Use 'xeft-default-extension'.
---
 xeft.el | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/xeft.el b/xeft.el
index e42fe2ebbb..4efc581560 100644
--- a/xeft.el
+++ b/xeft.el
@@ -67,9 +67,13 @@
   '((t . (:inherit highlight :extend t)))
   "Face for highlighting in the preview buffer.")
 
+(defcustom xeft-default-extension ".txt"
+  "The default extension for new files created by xeft.."
+  :type 'string)
+
 (defcustom xeft-filename-fn
   (lambda (search-phrase)
-    (concat search-phrase ".txt"))
+    (concat search-phrase xeft-default-extension))
   "A function that takes the search phrase and returns a filename."
   :type 'function)
 
@@ -165,6 +169,8 @@
     (mkdir xeft-directory t))
   (when (not (file-name-absolute-p xeft-database))
     (user-error "XEFT-DATABASE must be an absolute path"))
+  (when (not (file-exists-p xeft-database))
+    (mkdir xeft-database t))
   (unless (require 'xeft-module nil t)
     (when (y-or-n-p
            "Xeft needs the dynamic module to work, compile it now? ")
@@ -185,15 +191,14 @@
   "Create a new note with the current search phrase as the title."
   (interactive)
   (let* ((search-phrase (xeft--get-search-phrase))
-         (file-path (expand-file-name
-                     (funcall xeft-filename-fn search-phrase)
-                     xeft-directory))
+         (file-name (funcall xeft-filename-fn search-phrase))
+         (file-path (expand-file-name file-name xeft-directory))
          (exists-p (file-exists-p file-path)))
     ;; If there is no match, create the file without confirmation,
     ;; otherwise prompt for confirmation. NOTE: this is not DRY, but
     ;; should be ok.
     (when (or (search-forward "Press RET to create a new note" nil t)
-              (y-or-n-p (format "Create file `%s'.txt? " search-phrase)))
+              (y-or-n-p (format "Create file `%s'? " file-name)))
       (find-file file-path)
       (unless exists-p
         (insert search-phrase "\n\n")



reply via email to

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