aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPo Lu2025-04-29 08:28:16 +0800
committerPo Lu2025-04-29 08:28:19 +0800
commit3279194bf2c859e76c95045c80a033fc54094f07 (patch)
tree568b386e196056480961ca77678ea2a7f7101834
parent509cbe1c35b3dd005a53ac041f9c87ee53b8e115 (diff)
downloademacs-3279194bf2c859e76c95045c80a033fc54094f07.tar.gz
emacs-3279194bf2c859e76c95045c80a033fc54094f07.zip
Port Grep argument autodetection to Android
* lisp/progmodes/grep.el (grep-hello-file): On Android, copy sample text to a real directory.
-rw-r--r--lisp/progmodes/grep.el27
1 files changed, 20 insertions, 7 deletions
diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el
index ed64d8a5bc8..09610fdc74f 100644
--- a/lisp/progmodes/grep.el
+++ b/lisp/progmodes/grep.el
@@ -703,13 +703,26 @@ first capture group of `grep-heading-regexp'.")
703 (or result 0)))) 703 (or result 0))))
704 704
705(defun grep-hello-file () 705(defun grep-hello-file ()
706 (let ((result 706 (cond ((file-remote-p default-directory)
707 (if (file-remote-p default-directory) 707 (let ((file-name (make-temp-file
708 (make-temp-file (file-name-as-directory (temporary-file-directory))) 708 (file-name-as-directory
709 (expand-file-name "HELLO" data-directory)))) 709 (temporary-file-directory)))))
710 (when (file-remote-p result) 710 (when (file-remote-p result)
711 (write-region "Copyright\n" nil result)) 711 (write-region "Copyright\n" nil result))))
712 result)) 712 ((and (eq system-type 'android) (featurep 'android))
713 ;; /assets/etc is not accessible to grep or other shell
714 ;; commands on Android, and therefore the template must
715 ;; be copied to a location that is.
716 (let ((temp-file (concat temporary-file-directory
717 "grep-test.txt")))
718 (prog1 temp-file
719 (unless (file-regular-p temp-file)
720 ;; Create a temporary file if grep-text.txt can't be
721 ;; overwritten.
722 (when (file-exists-p temp-file)
723 (setq temp-file (make-temp-file "grep-test-")))
724 (write-region "Copyright\n" nil temp-file)))))
725 (t (expand-file-name "HELLO" data-directory))))
713 726
714;;;###autoload 727;;;###autoload
715(defun grep-compute-defaults () 728(defun grep-compute-defaults ()