[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/sesman 7bbd02be9e 083/100: Add sesman-follow-symlinks defc
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/sesman 7bbd02be9e 083/100: Add sesman-follow-symlinks defcustom |
Date: |
Tue, 28 Dec 2021 14:06:05 -0500 (EST) |
branch: elpa/sesman
commit 7bbd02be9eecc34b1573354b35bbc0535ee331a5
Author: JAremko <w3techplayground@gmail.com>
Commit: Vitalie Spinu <spinuvit@gmail.com>
Add sesman-follow-symlinks defcustom
---
sesman.el | 36 +++++++++++++++++++++++++++++++++---
1 file changed, 33 insertions(+), 3 deletions(-)
diff --git a/sesman.el b/sesman.el
index 7523e58698..0810cf3acc 100644
--- a/sesman.el
+++ b/sesman.el
@@ -42,6 +42,7 @@
(require 'cl-generic)
(require 'seq)
(require 'subr-x)
+(require 'vc)
(defgroup sesman nil
"Generic Session Manager."
@@ -72,6 +73,21 @@ sessions running in dependent projects."
:type 'boolean
:package-version '(sesman . "0.3.2"))
+(defcustom sesman-follow-symlinks 'auto
+ "This variable determines whether symlinks should be followed.
+nil - Don't follow symlinks - use `expand-file-name' for expanding file paths.
+t - Follow symlinks - use `file-truename' for expanding file paths.
+'auto - Don't follow symlink unless it's under version control and
+`vc-follow-link' has nil value. Or `find-file-visit-truename' is non-nil."
+ :group 'sesman
+ :type '(choice (const :tag "Behave like `find-file'" auto)
+ (const :tag "Don't follow symlinks" nil)
+ (const :tag "Follow symlinks" t))
+ :package-version '(sesman . "0.3.2"))
+(put 'sesman-follow-symlinks
+ 'safe-local-variable
+ (lambda (x) (memq x '(auto nil t))))
+
;; (defcustom sesman-disambiguate-by-relevance t
;; "If t choose most relevant session in ambiguous situations, otherwise ask.
;; Ambiguity arises when multiple sessions are associated with current
context. By
@@ -319,6 +335,16 @@ If SORT is non-nil, sort in relevance order."
(defun sesman--lnk-value (lnk)
(nth 2 lnk))
+(defun sesman--follow-symlink-p (filename)
+ "FILENAME predicate that tries to predict `find-file' behavior.
+It returns t if `find-file' will follow FILENAME symlink and nil if not."
+ (or find-file-visit-truename
+ (and vc-follow-symlinks
+ (let ((truename (file-truename filename)))
+ (and truename
+ (not (equal truename filename))
+ (vc-backend truename))))))
+
;;; User Interface
@@ -445,7 +471,7 @@ PROJECT defaults to current project. On universal argument,
or if PROJECT is
(or project (sesman-project system))))))
(sesman--link-session-interactively session 'project project)))
- ;;;###autoload
+;;;###autoload
(defun sesman-link-with-least-specific (&optional session)
"Ask for SESSION and link with the least specific context available.
Normally the least specific context is the project. If not in a project, link
@@ -917,8 +943,12 @@ buffers."
(defvar sesman--path-cache (make-hash-table :test #'equal))
;; path caching because file-truename is very slow
(defun sesman--expand-path (path)
- (or (gethash path sesman--path-cache)
- (puthash path (file-truename path) sesman--path-cache)))
+ (if (or (eq sesman-follow-symlinks t)
+ (and (eq sesman-follow-symlinks 'auto)
+ (sesman--follow-symlink-p path)))
+ (or (gethash path sesman--path-cache)
+ (puthash path (file-truename path) sesman--path-cache))
+ (expand-file-name path)))
(cl-defgeneric sesman-context (_cxt-type _system)
"Given SYSTEM and context type CXT-TYPE return the context.")
- [nongnu] elpa/sesman 4b2507d1ee 076/100: Optimize sesman-current-session, (continued)
- [nongnu] elpa/sesman 4b2507d1ee 076/100: Optimize sesman-current-session, ELPA Syncer, 2021/12/28
- [nongnu] elpa/sesman edee869c20 096/100: Sesman menu: Add Browser, Move Unlink, ELPA Syncer, 2021/12/28
- [nongnu] elpa/sesman 93123f6cef 093/100: Rename seman-menu-open -> sesman-menu-open, ELPA Syncer, 2021/12/28
- [nongnu] elpa/sesman 966c13812f 088/100: [Fix #14] Rewrite the usage of when-let*, ELPA Syncer, 2021/12/28
- [nongnu] elpa/sesman b527f7a638 043/100: Make sesman-system permanent local, ELPA Syncer, 2021/12/28
- [nongnu] elpa/sesman 95f8354d1a 041/100: Add sesman-relevant-[link|session]-p functions, ELPA Syncer, 2021/12/28
- [nongnu] elpa/sesman cf7997e279 035/100: Add sesman-project generic, ELPA Syncer, 2021/12/28
- [nongnu] elpa/sesman 0ea1d3e645 048/100: [Fix #7] Implement WHICH argument in `sesman-restart`, ELPA Syncer, 2021/12/28
- [nongnu] elpa/sesman 0e38d4e427 057/100: Remove unnecessary autoloads, ELPA Syncer, 2021/12/28
- [nongnu] elpa/sesman e4775a2e81 084/100: Remove sesman--expand-path-maybe, ELPA Syncer, 2021/12/28
- [nongnu] elpa/sesman 7bbd02be9e 083/100: Add sesman-follow-symlinks defcustom,
ELPA Syncer <=