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

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

[elpa] externals/vlf 9c50487 165/310: Introduce list of major modes wher


From: Stefan Monnier
Subject: [elpa] externals/vlf 9c50487 165/310: Introduce list of major modes where VLF will not activate.
Date: Sat, 28 Nov 2020 00:33:08 -0500 (EST)

branch: externals/vlf
commit 9c50487982aaecff9a8824e7aa2c08420ca9c956
Author: Andrey Kotlarski <m00naticus@gmail.com>
Commit: Andrey Kotlarski <m00naticus@gmail.com>

    Introduce list of major modes where VLF will not activate.
---
 vlf.el | 43 ++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 42 insertions(+), 1 deletion(-)

diff --git a/vlf.el b/vlf.el
index 9928d28..9bf8061 100644
--- a/vlf.el
+++ b/vlf.el
@@ -159,6 +159,45 @@ You can customize number of bytes displayed by customizing
 (eval-after-load "dired"
   '(define-key dired-mode-map "V" 'dired-vlf))
 
+;;;####autoload
+(defcustom vlf-forbidden-modes-list '(archive-mode tar-mode jka-compr
+                                                   git-commit-mode)
+  "Major modes which VLF will not be automatically applied to."
+  :group 'vlf
+  :type '(list symbol))
+
+;;;####autoload
+(defun vlf-determine-major-mode (filename)
+  "Determine major mode from FILENAME."
+  (let ((name filename)
+        (remote-id (file-remote-p filename))
+        mode)
+    ;; Remove backup-suffixes from file name.
+    (setq name (file-name-sans-versions name))
+    ;; Remove remote file name identification.
+    (and (stringp remote-id)
+         (string-match (regexp-quote remote-id) name)
+         (setq name (substring name (match-end 0))))
+    (setq mode
+          (if (memq system-type '(windows-nt cygwin))
+              ;; System is case-insensitive.
+              (let ((case-fold-search t))
+                (assoc-default name auto-mode-alist
+                               'string-match))
+            ;; System is case-sensitive.
+            (or ;; First match case-sensitively.
+             (let ((case-fold-search nil))
+               (assoc-default name auto-mode-alist
+                              'string-match))
+             ;; Fallback to case-insensitive match.
+             (and auto-mode-case-fold
+                  (let ((case-fold-search t))
+                    (assoc-default name auto-mode-alist
+                                   'string-match))))))
+    (if (and mode (consp mode))
+        (cadr mode)
+      mode)))
+
 ;;;###autoload
 (defadvice abort-if-file-too-large (around vlf-if-file-too-large
                                            (size op-type
@@ -168,7 +207,9 @@ You can customize number of bytes displayed by customizing
 allow user to view file with `vlf', open it normally, or abort.
 OP-TYPE specifies the file operation being performed over FILENAME."
   (cond
-   ((not vlf-application)
+   ((or (not vlf-application)
+        (memq (vlf-determine-major-mode filename)
+              vlf-forbidden-modes-list))
     ad-do-it)
    ((eq vlf-application 'always)
     (vlf filename)



reply via email to

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