From 9082b4e6ee27b995cbb61668cb437d7b91c7f5f8 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Tue, 24 Jan 2023 21:37:22 +0800 Subject: [PATCH] Make binaries distributed with Emacs work on Android * doc/lispref/processes.texi (Subprocess Creation): Document variables containing program names. * etc/NEWS: Document new variables. * java/Makefile.in (CROSS_BINS): Add missing etags binary. * lisp/cedet/semantic/db-ebrowse.el (semanticdb-create-ebrowse-database): * lisp/gnus/mail-source.el (mail-source-movemail-program): * lisp/hexl.el (hexl-program): * lisp/htmlfontify.el (hfy-etags-bin): * lisp/ielm.el (inferior-emacs-lisp-mode): * lisp/mail/rmail.el (rmail-autodetect): (rmail-insert-inbox-text): * lisp/org/org-ctags.el (org-ctags-path-to-ctags): * lisp/progmodes/cperl-mode.el (cperl-etags): * lisp/speedbar.el (speedbar-fetch-etags-command): * lisp/textmodes/reftex-global.el (reftex-create-tags-file): Use new variables. * src/callproc.c (syms_of_callproc): New variables naming binaries redistributed with Emacs. --- doc/lispref/processes.texi | 18 +++++++++ etc/NEWS | 8 ++++ java/Makefile.in | 4 +- lisp/cedet/semantic/db-ebrowse.el | 3 +- lisp/gnus/mail-source.el | 2 +- lisp/hexl.el | 2 +- lisp/htmlfontify.el | 5 ++- lisp/ielm.el | 2 +- lisp/mail/rmail.el | 6 ++- lisp/org/org-ctags.el | 4 +- lisp/progmodes/cperl-mode.el | 2 +- lisp/speedbar.el | 2 +- lisp/textmodes/reftex-global.el | 6 ++- src/callproc.c | 63 +++++++++++++++++++++++++++++++ 14 files changed, 113 insertions(+), 14 deletions(-) diff --git a/doc/lispref/processes.texi b/doc/lispref/processes.texi index 50e67475d8e..aa71e3ee131 100644 --- a/doc/lispref/processes.texi +++ b/doc/lispref/processes.texi @@ -185,6 +185,24 @@ respective remote host. In case of a local @code{default-directory}, the function returns just the value of the variable @code{exec-path}. @end defun +@cindex programs distributed with Emacs, starting +@vindex ctags-program-name +@vindex etags-program-name +@vindex hexl-program-name +@vindex emacsclient-program-name +@vindex movemail-program-name +@vindex ebrowse-program-manem + When starting a program that is part of the Emacs distribution, +you must take into account that the program may have been renamed in +order to comply with executable naming restrictions present on the +system. + + Instead of starting @command{ctags}, for example, you should specify +the value of @code{ctags-program-name} instead. Likewise, instead of +starting @command{movemail}, you must start +@code{movemail-program-name}, and the same goes for @command{etags}, +@command{hexl}, @command{emacsclient}, and @command{ebrowse}. + @node Shell Arguments @section Shell Arguments @cindex arguments for shell commands diff --git a/etc/NEWS b/etc/NEWS index 3a52492fd19..40f4364d8f6 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -238,6 +238,14 @@ This user option has been obsoleted in Emacs 27, use * Lisp Changes in Emacs 30.1 ++++ +** New variables describing the names of built in programs. +The new variables 'ctags-program-name', 'ebrowse-program-name', +'etags-program-name', 'hexl-program-name', 'emacsclient-program-name' +and 'movemail-program-name' should be used instead of "ctags", +"ebrowse", "etags", "hexl", and "emacsclient", when starting one of +these built in programs in a subprocess. + +++ ** 'x-popup-menu' now understands touch screen events. When a 'touchscreen-begin' or 'touchscreen-end' event is passed as the diff --git a/java/Makefile.in b/java/Makefile.in index b5e0cd7bb56..b32b2442305 100644 --- a/java/Makefile.in +++ b/java/Makefile.in @@ -69,6 +69,7 @@ APK_NAME = emacs-$(version)-$(ANDROID_MIN_SDK)-$(ANDROID_ABI).apk # lib/$(ANDROID_ABI)/libemacs.so # lib/$(ANDROID_ABI)/libandroid-emacs.so # lib/$(ANDROID_ABI)/libctags.so +# lib/$(ANDROID_ABI)/libetags.so # lib/$(ANDROID_ABI)/libhexl.so # lib/$(ANDROID_ABI)/libmovemail.so # lib/$(ANDROID_ABI)/librcs2log.so @@ -83,7 +84,8 @@ all: $(APK_NAME) # Binaries to cross-compile. CROSS_BINS = ../cross/src/android-emacs ../cross/lib-src/ctags \ ../cross/lib-src/hexl ../cross/lib-src/movemail \ - ../cross/lib-src/ebrowse ../cross/lib-src/emacsclient + ../cross/lib-src/ebrowse ../cross/lib-src/emacsclient \ + ../cross/lib-src/etags # Libraries to cross-compile. CROSS_LIBS = ../cross/src/libemacs.so diff --git a/lisp/cedet/semantic/db-ebrowse.el b/lisp/cedet/semantic/db-ebrowse.el index f8ea73cbdde..3e54b9e76cf 100644 --- a/lisp/cedet/semantic/db-ebrowse.el +++ b/lisp/cedet/semantic/db-ebrowse.el @@ -158,7 +158,8 @@ is specified by `semanticdb-default-save-directory'." ;; Call the EBROWSE command. (message "Creating ebrowse file: %s ..." savein) (call-process-region (point-min) (point-max) - "ebrowse" nil "*EBROWSE OUTPUT*" nil + ebrowse-program-name + nil "*EBROWSE OUTPUT*" nil (concat "--output-file=" savein) "--very-verbose") ) diff --git a/lisp/gnus/mail-source.el b/lisp/gnus/mail-source.el index 639a29582b3..82cb7ddd8ad 100644 --- a/lisp/gnus/mail-source.el +++ b/lisp/gnus/mail-source.el @@ -285,7 +285,7 @@ number." "Number of idle seconds to wait before checking for new mail." :type 'number) -(defcustom mail-source-movemail-program "movemail" +(defcustom mail-source-movemail-program movemail-program-name "If non-nil, name of program for fetching new mail." :version "26.2" :type '(choice (const nil) string)) diff --git a/lisp/hexl.el b/lisp/hexl.el index bb57f4ac4c3..5fa09459a46 100644 --- a/lisp/hexl.el +++ b/lisp/hexl.el @@ -60,7 +60,7 @@ (const 64)) :version "24.3") -(defcustom hexl-program "hexl" +(defcustom hexl-program hexl-program-name "The program that will hexlify and dehexlify its stdin. `hexl-program' will always be concatenated with `hexl-options' and \"-de\" when dehexlifying a buffer." diff --git a/lisp/htmlfontify.el b/lisp/htmlfontify.el index 1ab33cc6411..a06387687b9 100644 --- a/lisp/htmlfontify.el +++ b/lisp/htmlfontify.el @@ -308,13 +308,14 @@ done;") :tag "etags-cmd-alist" :type '(alist :key-type (string) :value-type (string))) -(defcustom hfy-etags-bin "etags" +(defcustom hfy-etags-bin etags-program-name "Location of etags binary (we begin by assuming it's in your path). Note that if etags is not in your path, you will need to alter the shell commands in `hfy-etags-cmd-alist'." :tag "etags-bin" - :type '(file)) + :type '(file) + :version "30.1") (defcustom hfy-shell-file-name "/bin/sh" "Shell (Bourne or compatible) to invoke for complex shell operations." diff --git a/lisp/ielm.el b/lisp/ielm.el index 5c370733c05..1eeec5fbb84 100644 --- a/lisp/ielm.el +++ b/lisp/ielm.el @@ -605,7 +605,7 @@ Customized bindings may be defined in `ielm-map', which currently contains: ;; Was cat, but on non-Unix platforms that might not exist, so ;; use hexl instead, which is part of the Emacs distribution. (condition-case nil - (start-process "ielm" (current-buffer) "hexl") + (start-process "ielm" (current-buffer) hexl-program-name) (file-error (start-process "ielm" (current-buffer) "cat"))) (set-process-query-on-exit-flag (ielm-process) nil) (goto-char (point-max)) diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el index 659649b5d42..0572283b609 100644 --- a/lisp/mail/rmail.el +++ b/lisp/mail/rmail.el @@ -263,7 +263,7 @@ Otherwise, look for `movemail' in the directories in ;; assuming it would work. ;; https://lists.gnu.org/r/bug-gnu-emacs/2008-02/msg00087.html (let ((progname (expand-file-name - (concat "movemail" + (concat movemail-program-name (if (memq system-type '(ms-dos windows-nt)) ".exe")) dir))) (when (and (not (file-directory-p progname)) @@ -1989,7 +1989,9 @@ Value is the size of the newly read mail after conversion." (buffer-disable-undo errors) (let ((args (append - (list (or rmail-movemail-program "movemail") nil errors nil) + (list (or rmail-movemail-program + movemail-program-name) + nil errors nil) (if rmail-preserve-inbox (list "-p") nil) diff --git a/lisp/org/org-ctags.el b/lisp/org/org-ctags.el index 5dd2bfd59cd..990214f4117 100644 --- a/lisp/org/org-ctags.el +++ b/lisp/org/org-ctags.el @@ -156,7 +156,9 @@ Format is: /REGEXP/TAGNAME/FLAGS,TAGTYPE/ See the ctags documentation for more information.") (defcustom org-ctags-path-to-ctags - (if (executable-find "ctags-exuberant") "ctags-exuberant" "ctags") + (if (executable-find "ctags-exuberant") + "ctags-exuberant" + ctags-program-name) "Name of the ctags executable file." :version "24.1" :type 'file) diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el index 412283f3488..9f79834f964 100644 --- a/lisp/progmodes/cperl-mode.el +++ b/lisp/progmodes/cperl-mode.el @@ -6533,7 +6533,7 @@ in subdirectories too." ;; of etags has been commented out in the menu since ... well, ;; forever. So, let's just stick to ASCII here. -- haj, 2021-09-14 (interactive) - (let ((cmd "etags") + (let ((cmd etags-program-name) (args `("-l" "none" "-r" ;; 1=fullname 2=package? 3=name 4=proto? 5=attrs? (VERY APPROX!) ,(concat diff --git a/lisp/speedbar.el b/lisp/speedbar.el index 60113ca1410..2f1d9d22110 100644 --- a/lisp/speedbar.el +++ b/lisp/speedbar.el @@ -3532,7 +3532,7 @@ to be at the beginning of a line in the etags buffer. This variable is ignored if `speedbar-use-imenu-flag' is non-nil.") -(defcustom speedbar-fetch-etags-command "etags" +(defcustom speedbar-fetch-etags-command etags-program-name "Command used to create an etags file. This variable is ignored if `speedbar-use-imenu-flag' is t." :group 'speedbar diff --git a/lisp/textmodes/reftex-global.el b/lisp/textmodes/reftex-global.el index acf0891432f..b8b0ae6a061 100644 --- a/lisp/textmodes/reftex-global.el +++ b/lisp/textmodes/reftex-global.el @@ -39,8 +39,10 @@ The TAGS file is also immediately visited with `visit-tags-table'." (reftex-access-scan-info current-prefix-arg) (let* ((master (reftex-TeX-master-file)) (files (reftex-all-document-files)) - (cmd (format "etags %s" (mapconcat #'shell-quote-argument - files " ")))) + (cmd (format "%s %s" + etags-program-name + (mapconcat #'shell-quote-argument + files " ")))) (with-current-buffer (reftex-get-file-buffer-force master) (message "Running etags to create TAGS file...") (shell-command cmd) diff --git a/src/callproc.c b/src/callproc.c index 5e1e1a8cc0a..85895a7d9f2 100644 --- a/src/callproc.c +++ b/src/callproc.c @@ -2110,6 +2110,69 @@ use. See `setenv' and `getenv'. */); Vprocess_environment = Qnil; + DEFVAR_LISP ("ctags-program-name", Vctags_program_name, + doc: /* Name of the `ctags' program distributed with Emacs. +Use this instead of calling `ctags' directly, as `ctags' may have been +renamed to comply with executable naming restrictions on the system. */); +#if !defined HAVE_ANDROID || defined ANDROID_STUBIFY + Vctags_program_name = build_pure_c_string ("ctags"); +#else + Vctags_program_name = build_pure_c_string ("libctags.so"); +#endif + + DEFVAR_LISP ("etags-program-name", Vetags_program_name, + doc: /* Name of the `etags' program distributed with Emacs. +Use this instead of calling `etags' directly, as `etags' may have been +renamed to comply with executable naming restrictions on the system. */); +#if !defined HAVE_ANDROID || defined ANDROID_STUBIFY + Vetags_program_name = build_pure_c_string ("etags"); +#else + Vetags_program_name = build_pure_c_string ("libetags.so"); +#endif + + DEFVAR_LISP ("hexl-program-name", Vhexl_program_name, + doc: /* Name of the `hexl' program distributed with Emacs. +Use this instead of calling `hexl' directly, as `hexl' may have been +renamed to comply with executable naming restrictions on the system. */); +#if !defined HAVE_ANDROID || defined ANDROID_STUBIFY + Vhexl_program_name = build_pure_c_string ("hexl"); +#else + Vhexl_program_name = build_pure_c_string ("libhexl.so"); +#endif + + DEFVAR_LISP ("emacsclient-program-name", Vemacsclient_program_name, + doc: /* Name of the `emacsclient' program distributed with Emacs. +Use this instead of calling `emacsclient' directly, as `emacsclient' +may have been renamed to comply with executable naming restrictions on +the system. */); +#if !defined HAVE_ANDROID || defined ANDROID_STUBIFY + Vemacsclient_program_name = build_pure_c_string ("emacsclient"); +#else + Vemacsclient_program_name = build_pure_c_string ("libemacsclient.so"); +#endif + + DEFVAR_LISP ("movemail-program-name", Vmovemail_program_name, + doc: /* Name of the `movemail' program distributed with Emacs. +Use this instead of calling `movemail' directly, as `movemail' +may have been renamed to comply with executable naming restrictions on +the system. */); +#if !defined HAVE_ANDROID || defined ANDROID_STUBIFY + Vmovemail_program_name = build_pure_c_string ("movemail"); +#else + Vmovemail_program_name = build_pure_c_string ("libmovemail.so"); +#endif + + DEFVAR_LISP ("ebrowse-program-name", Vebrowse_program_name, + doc: /* Name of the `ebrowse' program distributed with Emacs. +Use this instead of calling `ebrowse' directly, as `ebrowse' +may have been renamed to comply with executable naming restrictions on +the system. */); +#if !defined HAVE_ANDROID || defined ANDROID_STUBIFY + Vebrowse_program_name = build_pure_c_string ("ebrowse"); +#else + Vebrowse_program_name = build_pure_c_string ("libebrowse.so"); +#endif + defsubr (&Scall_process); defsubr (&Sgetenv_internal); defsubr (&Scall_process_region); -- 2.39.5