emacs-devel
[Top][All Lists]
Advanced

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

hexl and running a shell


From: Stefan Monnier
Subject: hexl and running a shell
Date: Fri, 30 Nov 2001 05:00:57 -0500

For some reason, `hexl' currently uses shell-command-on-region
even though it doesn't use any particular feature of the shell.
I use the patch below which makes it use call-process-region
instead.
The reason why I have such a patch is because a user on
gun.emacs.help complained that hexl wasn't working (his shell
was adding some text to standard output and confusing hexl-mode).
It was arguably a misconfiguration on his part, but OTOH there's
really no good reason why hexl-mode should use the shell.


        Stefan


Index: hexl.el
===================================================================
RCS file: /cvs/emacs/lisp/hexl.el,v
retrieving revision 1.70
diff -u -u -b -r1.70 hexl.el
--- hexl.el     2001/11/26 16:27:00     1.70
+++ hexl.el     2001/11/30 09:57:09
@@ -72,26 +72,22 @@
   :group 'hexl)
 
 (defcustom hexl-options (format "-hex %s" hexl-iso)
-  "Options to hexl-program that suit your needs."
+  "Options to `hexl-program' that suit your needs."
   :type 'string
   :group 'hexl)
 
 (defcustom hexlify-command
-  (format "%s %s"
-         (shell-quote-argument
-          (expand-file-name hexl-program exec-directory))
-         hexl-options)
+  (cons (expand-file-name hexl-program exec-directory)
+       (split-string hexl-options))
   "The command to use to hexlify a buffer."
-  :type 'string
+  :type '(repeat string)
   :group 'hexl)
 
 (defcustom dehexlify-command
-  (format "%s -de %s"
-         (shell-quote-argument
-          (expand-file-name hexl-program exec-directory))
-         hexl-options)
+  (cons (expand-file-name hexl-program exec-directory)
+       (cons "-de" (split-string hexl-options)))
   "The command to use to unhexlify a buffer."
-  :type 'string
+  :type '(repeat string)
   :group 'hexl)
 
 (defcustom hexl-follow-ascii t
@@ -634,7 +630,10 @@
   (let ((coding-system-for-read 'raw-text)
        (coding-system-for-write buffer-file-coding-system)
        (buffer-undo-list t))
-    (shell-command-on-region (point-min) (point-max) hexlify-command t)
+    (if (stringp hexlify-command)
+       (setq hexlify-command (split-string hexlify-command)))
+    (apply 'call-process-region (point-min) (point-max)
+          (car hexlify-command) t t nil (cdr hexlify-command))
     (if (> (point) (hexl-address-to-marker hexl-max-address))
        (hexl-goto-address hexl-max-address))))
 
@@ -649,7 +648,10 @@
   (let ((coding-system-for-write 'raw-text)
        (coding-system-for-read buffer-file-coding-system)
        (buffer-undo-list t))
-    (shell-command-on-region (point-min) (point-max) dehexlify-command t)))
+    (if (stringp dehexlify-command)
+       (setq dehexlify-command (split-string dehexlify-command)))
+    (apply 'call-process-region (point-min) (point-max)
+          (car dehexlify-command) t t nil (cdr dehexlify-command))))
 
 (defun hexl-char-after-point ()
   "Return char for ASCII hex digits at point."




reply via email to

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