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

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

[elpa] externals/muse 92922b23d3 03/14: make new behaviour configurable


From: Stefan Monnier
Subject: [elpa] externals/muse 92922b23d3 03/14: make new behaviour configurable
Date: Fri, 9 Feb 2024 18:40:43 -0500 (EST)

branch: externals/muse
commit 92922b23d3fa38e275fade1e81f9e94a22277a34
Author: Alex Ott <alexott@gmail.com>
Commit: Alex Ott <alexott@gmail.com>

    make new behaviour configurable
---
 lisp/muse-mode.el | 28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/lisp/muse-mode.el b/lisp/muse-mode.el
index 79e528a8b1..da8613baf0 100644
--- a/lisp/muse-mode.el
+++ b/lisp/muse-mode.el
@@ -563,19 +563,27 @@ Do not rename the page originally referred to."
          t t))
     (error "There is no valid link at point")))
 
+(defcustom muse-add-extension-p t
+  "If nil, open file link as-is
+If non-nil, append muse-file-extension to file name if it has none."
+  :type 'boolean
+  :group 'muse)
+
 (defun muse-get-link-filename (link)
   "Generates correct file name for given link, when source file doesn't belong 
to any
 project. Creates directory if link contains directory part, and it doesn't 
exists"
-  (let ((directory (file-name-directory link))
-       (filename (file-name-nondirectory link)))
-    (when (and (not (file-name-extension filename))
-              muse-file-extension
-              (not (string= muse-file-extension ""))
-              (not (file-exists-p link)))
-      (setq filename (concat filename "." muse-file-extension)))
-    (when (and directory (not (file-exists-p directory)))
-      (make-directory directory t))    
-    (expand-file-name filename directory)))
+  (if muse-add-extension-p
+      (let ((directory (file-name-directory link))
+           (filename (file-name-nondirectory link)))
+       (when (and (not (file-name-extension filename))
+                  muse-file-extension
+                  (not (string= muse-file-extension ""))
+                  (not (file-exists-p link)))
+         (setq filename (concat filename "." muse-file-extension)))
+       (when (and directory (not (file-exists-p directory)))
+         (make-directory directory t))    
+       (expand-file-name filename directory))
+    link))
 
 (defun muse-visit-link-default (link &optional other-window)
   "Visit the URL or link named by LINK.



reply via email to

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