emacs-diffs
[Top][All Lists]
Advanced

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

master 21af3a9d970: Disable VC in special directories on Android


From: Po Lu
Subject: master 21af3a9d970: Disable VC in special directories on Android
Date: Sat, 30 Mar 2024 03:05:50 -0400 (EDT)

branch: master
commit 21af3a9d9706baa417298e70260efa3fce72c6f1
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Disable VC in special directories on Android
    
    * lisp/vc/vc-hooks.el (vc-registered, vc-backend): Return nil
    without invoking any backend if FILE or FILE-OR-LIST sits within
    /content or /assets.
---
 lisp/vc/vc-hooks.el | 80 +++++++++++++++++++++++++++++++----------------------
 1 file changed, 47 insertions(+), 33 deletions(-)

diff --git a/lisp/vc/vc-hooks.el b/lisp/vc/vc-hooks.el
index 75f68dd80d1..8f212e96933 100644
--- a/lisp/vc/vc-hooks.el
+++ b/lisp/vc/vc-hooks.el
@@ -326,30 +326,37 @@ This function performs the check each time it is called.  
To rely
 on the result of a previous call, use `vc-backend' instead.  If the
 file was previously registered under a certain backend, then that
 backend is tried first."
-  (let (handler)
-    (cond
-     ((and (file-name-directory file)
-           (string-match vc-ignore-dir-regexp (file-name-directory file)))
-      nil)
-     ((setq handler (find-file-name-handler file 'vc-registered))
-      ;; handler should set vc-backend and return t if registered
-      (funcall handler 'vc-registered file))
-     (t
-      ;; There is no file name handler.
-      ;; Try vc-BACKEND-registered for each handled BACKEND.
-      (catch 'found
-       (let ((backend (vc-file-getprop file 'vc-backend)))
-         (mapc
-          (lambda (b)
-            (and (vc-call-backend b 'registered file)
-                 (vc-file-setprop file 'vc-backend b)
-                 (throw 'found t)))
-          (if (or (not backend) (eq backend 'none))
-              vc-handled-backends
-            (cons backend vc-handled-backends))))
-        ;; File is not registered.
-        (vc-file-setprop file 'vc-backend 'none)
-        nil)))))
+  ;; Subprocesses (and with them, VC backends) can't run from /contents
+  ;; or /actions, which are fictions maintained by Emacs that do not
+  ;; exist in the filesystem.
+  (if (and (eq system-type 'android)
+           (string-match-p "/\\(content\\|assets\\)[/$]"
+                           (expand-file-name file)))
+      nil
+    (let (handler)
+      (cond
+       ((and (file-name-directory file)
+             (string-match vc-ignore-dir-regexp (file-name-directory file)))
+        nil)
+       ((setq handler (find-file-name-handler file 'vc-registered))
+        ;; handler should set vc-backend and return t if registered
+        (funcall handler 'vc-registered file))
+       (t
+        ;; There is no file name handler.
+        ;; Try vc-BACKEND-registered for each handled BACKEND.
+        (catch 'found
+         (let ((backend (vc-file-getprop file 'vc-backend)))
+           (mapc
+            (lambda (b)
+              (and (vc-call-backend b 'registered file)
+                   (vc-file-setprop file 'vc-backend b)
+                   (throw 'found t)))
+            (if (or (not backend) (eq backend 'none))
+                vc-handled-backends
+              (cons backend vc-handled-backends))))
+          ;; File is not registered.
+          (vc-file-setprop file 'vc-backend 'none)
+          nil))))))
 
 (defun vc-backend (file-or-list)
   "Return the version control type of FILE-OR-LIST, nil if it's not registered.
@@ -357,15 +364,22 @@ If the argument is a list, the files must all have the 
same back end."
   ;; `file' can be nil in several places (typically due to the use of
   ;; code like (vc-backend buffer-file-name)).
   (cond ((stringp file-or-list)
-        (let ((property (vc-file-getprop file-or-list 'vc-backend)))
-          ;; Note that internally, Emacs remembers unregistered
-          ;; files by setting the property to `none'.
-          (cond ((eq property 'none) nil)
-                (property)
-                ;; vc-registered sets the vc-backend property
-                (t (if (vc-registered file-or-list)
-                       (vc-file-getprop file-or-list 'vc-backend)
-                     nil)))))
+         ;; Subprocesses (and with them, VC backends) can't run from
+         ;; /contents or /actions, which are fictions maintained by
+         ;; Emacs that do not exist in the filesystem.
+         (if (and (eq system-type 'android)
+                  (string-match-p "/\\(content\\|assets\\)[/$]"
+                                  (expand-file-name file-or-list)))
+             nil
+          (let ((property (vc-file-getprop file-or-list 'vc-backend)))
+            ;; Note that internally, Emacs remembers unregistered
+            ;; files by setting the property to `none'.
+            (cond ((eq property 'none) nil)
+                  (property)
+                  ;; vc-registered sets the vc-backend property
+                  (t (if (vc-registered file-or-list)
+                         (vc-file-getprop file-or-list 'vc-backend)
+                       nil))))))
        ((and file-or-list (listp file-or-list))
         (vc-backend (car file-or-list)))
        (t



reply via email to

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