Ar an naoiú lá de mí Deireadh Fómhair, scríobh Nelson Ferreira:
> [...] Is there a well known restriction here ?
I think the short answer is no!
I’ve committed the below, which adds support for faces and display table
info, but it still doesn’t support begin glyphs and end glyphs. Maybe it
should.
# HG changeset patch
# User Aidan Kehoe <kehoea(a)parhasard.net>
# Date 1350227665 -3600
# Node ID b6c506c30f93e8b9f06c6b9e5d6d0dcc9cd3f5c3
# Parent 965a9ddc915a9a300afedd57e4bd43d69ea4f2d0
Respect face and display table information for the minibuffer prompt.
src/ChangeLog addition:
2012-10-14 Aidan Kehoe <kehoea(a)parhasard.net>
Respect face and display table information in the minibuffer
prompt. Thanks for the bug report, Nelson Ferreira!
* redisplay.c (struct prop_block):
Add entries representing the minibuffer prompt explicitly to the
union here.
* redisplay.c (add_propagation_runes):
Respect the face and the display table for the minibuffer prompt
here.
* redisplay.c (regenerate_window):
Use the new union members when passing the minibuffer prompt info
to add_propagation_runes().
diff -r 965a9ddc915a -r b6c506c30f93 src/ChangeLog
--- a/src/ChangeLog Sat Oct 13 01:09:35 2012 +0200
+++ b/src/ChangeLog Sun Oct 14 16:14:25 2012 +0100
@@ -1,3 +1,17 @@
+2012-10-14 Aidan Kehoe <kehoea(a)parhasard.net>
+
+ Respect face and display table information in the minibuffer
+ prompt. Thanks for the bug report, Nelson Ferreira!
+ * redisplay.c (struct prop_block):
+ Add entries representing the minibuffer prompt explicitly to the
+ union here.
+ * redisplay.c (add_propagation_runes):
+ Respect the face and the display table for the minibuffer prompt
+ here.
+ * redisplay.c (regenerate_window):
+ Use the new union members when passing the minibuffer prompt info
+ to add_propagation_runes().
+
2012-09-16 Aidan Kehoe <kehoea(a)parhasard.net>
* editfns.c (Fformat_time_string):
diff -r 965a9ddc915a -r b6c506c30f93 src/redisplay.c
--- a/src/redisplay.c Sat Oct 13 01:09:35 2012 +0200
+++ b/src/redisplay.c Sun Oct 14 16:14:25 2012 +0100
@@ -259,6 +259,12 @@
int width;
Lisp_Object glyph;
} p_glyph;
+
+ struct
+ {
+ Lisp_Object preprompt;
+ Lisp_Object prompt;
+ } p_minibuf_prompt;
} data;
};
@@ -1692,30 +1698,77 @@
{
face_index old_findex = data->findex;
Bytebpos byte_old_charpos = data->byte_charpos;
-
- data->findex = DEFAULT_INDEX;
+ Boolint stop_after = NILP (pb->data.p_minibuf_prompt.preprompt);
+ Lisp_Object str = stop_after ? pb->data.p_minibuf_prompt.prompt
+: pb->data.p_minibuf_prompt.preprompt;
+ struct window *w = XWINDOW (data->window);
+
data->byte_charpos = 0;
data->cursor_type = NO_CURSOR;
- while (pb->data.p_string.len > 0)
- {
- data->ch = itext_ichar (pb->data.p_string.str);
- add_failed = add_ichar_rune (data);
-
- if (add_failed)
- {
- data->findex = old_findex;
- data->byte_charpos = byte_old_charpos;
- goto oops_no_more_space;
+ /* This doesn't handle begin-glyphs and end-glyphs and so on. It
+ may be reasonable not to, given that we're a "propagation
+ glyph", but it's not intuitively clear either way. It is
+ clear that it should handle the face and the display
+ table. */
+
+ while (STRINGP (str))
+ {
+ Ibyte *pstart = XSTRING_DATA (str), *pp = pstart,
+ *pend = pstart + XSTRING_LENGTH (str);
+ struct extent_fragment *ef
+ = extent_fragment_new (str, XFRAME (w->frame));
+
+ while (pp < pend)
+ {
+ Lisp_Object face_dt, window_dt, entry = Qnil;
+ face_index new_findex
+ = data->findex = extent_fragment_update (w, ef,
+ pp - pstart,
+ Qnil);
+
+ data->ch = itext_ichar (pp);
+ get_display_tables (w, new_findex, &face_dt, &window_dt);
+
+ if (!NILP (face_dt) || !NILP (window_dt))
+ {
+ entry = display_table_entry (data->ch, face_dt,
+ window_dt);
+ }
+
+ /* If there is a display table entry for it, hand it off
+ to add_disp_table_entry_runes and let it worry about
+ it. */
+ if (!NILP (entry) && !EQ (entry, make_char (data->ch)))
+ {
+ add_failed = add_disp_table_entry_runes (data, entry);
+ }
+ else
+ {
+ add_failed = add_ichar_rune (data);
+ }
+
+ if (add_failed)
+ {
+ data->findex = old_findex;
+ data->byte_charpos = byte_old_charpos;
+ extent_fragment_delete (ef);
+ goto oops_no_more_space;
+ }
+
+ INC_IBYTEPTR (pp);
}
- else
- {
- /* Complicated equivalent of ptr++, len-- */
- Ibyte *oldpos = pb->data.p_string.str;
- INC_IBYTEPTR (pb->data.p_string.str);
- pb->data.p_string.len -= pb->data.p_string.str - oldpos;
- }
- }
+
+ extent_fragment_delete (ef);
+
+ if (stop_after)
+ {
+ break;
+ }
+
+ str = pb->data.p_minibuf_prompt.prompt;
+ stop_after = 1;
+ }
data->findex = old_findex;
/* ##### FIXME FIXME FIXME -- Upon successful return from
@@ -5523,13 +5576,11 @@
&& start_pos == BUF_BEGV (b))
{
struct prop_block pb;
- Lisp_Object string;
prop = Dynarr_new (prop_block);
- string = concat2 (Vminibuf_preprompt, Vminibuf_prompt);
pb.type = PROP_MINIBUF_PROMPT;
- pb.data.p_string.str = XSTRING_DATA (string);
- pb.data.p_string.len = XSTRING_LENGTH (string);
+ pb.data.p_minibuf_prompt.preprompt = Vminibuf_preprompt;
+ pb.data.p_minibuf_prompt.prompt = Vminibuf_prompt;
Dynarr_add (prop, pb);
}
else
--
‘Liston operated so fast that he once accidentally amputated an assistant’s
fingers along with a patient’s leg, […] The patient and the assistant both
died of sepsis, and a spectator reportedly died of shock, resulting in the
only known procedure with a 300% mortality.’ (Atul Gawande, NEJM, 2012)
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://lists.xemacs.org/mailman/listinfo/xemacs-patches
APPROVE COMMIT
NOTE: This patch has been committed
# HG changeset patch
# User Mats Lidell <matsl(a)xemacs.org>
# Date 1350083375 -7200
# Node ID 965a9ddc915a9a300afedd57e4bd43d69ea4f2d0
# Parent c6b1500299a7dc7c7fd5476d169a2478555dcf37
Introduce call-process-shell-command from GNU.
Thanks GNU. Used in recent versions of org-mode.
2012-10-13 Mats Lidell <matsl(a)xemacs.org>
* process.el (call-process-shell-command): New function from GNU.
2012-10-13 Mats Lidell <matsl(a)xemacs.org>
* lispref/processes.texi (Synchronous Processes): New function
call-process-shell-command.
2012-10-13 Mats Lidell <matsl(a)xemacs.org>
* automated/process-tests.el: Simple test cases for
call-process-shell-command.
diff -r c6b1500299a7 -r 965a9ddc915a lisp/ChangeLog
--- a/lisp/ChangeLog Tue Sep 18 08:58:28 2012 +0200
+++ b/lisp/ChangeLog Sat Oct 13 01:09:35 2012 +0200
@@ -1,3 +1,7 @@
+2012-10-13 Mats Lidell <matsl(a)xemacs.org>
+
+ * process.el (call-process-shell-command): New function from GNU.
+
2012-09-18 Mats Lidell <matsl(a)xemacs.org>
* window-xemacs.el (recenter-positions): New defcustom.
diff -r c6b1500299a7 -r 965a9ddc915a lisp/process.el
--- a/lisp/process.el Tue Sep 18 08:58:28 2012 +0200
+++ b/lisp/process.el Sat Oct 13 01:09:35 2012 +0200
@@ -1,6 +1,6 @@
;;; process.el --- commands for subprocesses; split out of simple.el
-;; Copyright (C) 1985-7, 1993,4, 1997, 2011 Free Software Foundation, Inc.
+;; Copyright (C) 1985-7, 1993,4, 1997, 2011, 2012 Free Software Foundation, Inc.
;; Copyright (C) 1995, 2000, 2001, 2002 Ben Wing.
;; Author: Ben Wing
@@ -81,6 +81,34 @@
(start-process name buffer shell-file-name shell-command-switch
(mapconcat #'identity args " ")))
+(defun call-process-shell-command (command &optional infile buffer display
+ &rest args)
+ "Execute the shell command COMMAND synchronously in separate process.
+The remaining arguments are optional.
+The program's input comes from file INFILE (nil means `/dev/null').
+Insert output in BUFFER before point; t means current buffer;
+ nil for BUFFER means discard it; 0 means discard and don't wait.
+BUFFER can also have the form (REAL-BUFFER STDERR-FILE); in that case,
+REAL-BUFFER says what to do with standard output, as above,
+while STDERR-FILE says what to do with standard error in the child.
+STDERR-FILE may be nil (discard standard error output),
+t (mix it with ordinary output), or a file name string.
+
+Fourth arg DISPLAY non-nil means redisplay buffer as output is inserted.
+Remaining arguments are strings passed as additional arguments for COMMAND.
+Wildcards and redirection are handled as usual in the shell.
+
+If BUFFER is 0, `call-process-shell-command' returns immediately with value nil.
+Otherwise it waits for COMMAND to terminate and returns a numeric exit
+status or a signal description string.
+If you quit, the process is killed with SIGINT, or SIGKILL if you quit again."
+ ;; We used to use `exec' to replace the shell with the command,
+ ;; but that failed to handle (...) and semicolon, etc.
+ (call-process shell-file-name
+ infile buffer display
+ shell-command-switch
+ (mapconcat 'identity (cons command args) " ")))
+
(defun process-synchronize-point (proc)
"Set the point(s) in buffer and stderr-buffer according to the process mark."
;; We need this because the documentation says to insert *BEFORE* point,
diff -r c6b1500299a7 -r 965a9ddc915a man/ChangeLog
--- a/man/ChangeLog Tue Sep 18 08:58:28 2012 +0200
+++ b/man/ChangeLog Sat Oct 13 01:09:35 2012 +0200
@@ -1,3 +1,8 @@
+2012-10-13 Mats Lidell <matsl(a)xemacs.org>
+
+ * lispref/processes.texi (Synchronous Processes): New function
+ call-process-shell-command.
+
2012-09-18 Mats Lidell <matsl(a)xemacs.org>
* lispref/windows.texi (Vertical Scrolling): Added
diff -r c6b1500299a7 -r 965a9ddc915a man/lispref/processes.texi
--- a/man/lispref/processes.texi Tue Sep 18 08:58:28 2012 +0200
+++ b/man/lispref/processes.texi Sat Oct 13 01:09:35 2012 +0200
@@ -309,6 +309,13 @@
@end smallexample
@end defun
+@defun call-process-shell-command command &optional infile destination display &rest args
+This function executes the shell command @var{command} synchronously.
+The final arguments @var{args} are additional arguments to add at the
+end of @var{command}. The other arguments are handled as in
+@code{call-process}.
+@end defun
+
@node MS-DOS Subprocesses
@section MS-DOS Subprocesses
diff -r c6b1500299a7 -r 965a9ddc915a tests/ChangeLog
--- a/tests/ChangeLog Tue Sep 18 08:58:28 2012 +0200
+++ b/tests/ChangeLog Sat Oct 13 01:09:35 2012 +0200
@@ -1,3 +1,8 @@
+2012-10-13 Mats Lidell <matsl(a)xemacs.org>
+
+ * automated/process-tests.el: Simple test cases for
+ call-process-shell-command.
+
2012-09-02 Aidan Kehoe <kehoea(a)parhasard.net>
* automated/regexp-tests.el:
diff -r c6b1500299a7 -r 965a9ddc915a tests/automated/process-tests.el
--- a/tests/automated/process-tests.el Tue Sep 18 08:58:28 2012 +0200
+++ b/tests/automated/process-tests.el Sat Oct 13 01:09:35 2012 +0200
@@ -1,4 +1,4 @@
-;; Copyright (C) 2011 Free Software Foundation, Inc.
+;; Copyright (C) 2011, 2012 Free Software Foundation, Inc.
;; Author: Mats Lidell <matsl(a)xemacs.org>
;; Maintainer:
@@ -67,4 +67,18 @@
(with-current-buffer "Output buffer"
(goto-char (point-min))
(Assert (looking-at "foobar")))
-)
+ )
+
+;; call-process-shell-command
+(when (equal system-type 'linux)
+ (setenv "LANG" "C")
+
+ ;; Output one line
+ (Assert (= 0 (call-process-shell-command "echo hello")))
+
+ ;; Output to stderr but no error buffer
+ (Assert (= 0 (call-process-shell-command "echo -e \"barefoot\nfoobar\n\" 1>&2" nil "Output buffer")))
+ (with-current-buffer "Output buffer"
+ (goto-char (point-min))
+ (Assert (looking-at "barefoot\n")))
+ )
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://lists.xemacs.org/mailman/listinfo/xemacs-patches
1 new commit in XEmacs:
https://bitbucket.org/xemacs/xemacs/changeset/965a9ddc915a/
changeset: 965a9ddc915a
user: matsl
date: 2012-10-13 01:09:35
summary: Introduce call-process-shell-command from GNU.
Thanks GNU. Used in recent versions of org-mode.
2012-10-13 Mats Lidell <matsl(a)xemacs.org>
* process.el (call-process-shell-command): New function from GNU.
2012-10-13 Mats Lidell <matsl(a)xemacs.org>
* lispref/processes.texi (Synchronous Processes): New function
call-process-shell-command.
2012-10-13 Mats Lidell <matsl(a)xemacs.org>
* automated/process-tests.el: Simple test cases for
call-process-shell-command.
affected #: 6 files
diff -r c6b1500299a7dc7c7fd5476d169a2478555dcf37 -r 965a9ddc915a9a300afedd57e4bd43d69ea4f2d0 lisp/ChangeLog
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,7 @@
+2012-10-13 Mats Lidell <matsl(a)xemacs.org>
+
+ * process.el (call-process-shell-command): New function from GNU.
+
2012-09-18 Mats Lidell <matsl(a)xemacs.org>
* window-xemacs.el (recenter-positions): New defcustom.
diff -r c6b1500299a7dc7c7fd5476d169a2478555dcf37 -r 965a9ddc915a9a300afedd57e4bd43d69ea4f2d0 lisp/process.el
--- a/lisp/process.el
+++ b/lisp/process.el
@@ -1,6 +1,6 @@
;;; process.el --- commands for subprocesses; split out of simple.el
-;; Copyright (C) 1985-7, 1993,4, 1997, 2011 Free Software Foundation, Inc.
+;; Copyright (C) 1985-7, 1993,4, 1997, 2011, 2012 Free Software Foundation, Inc.
;; Copyright (C) 1995, 2000, 2001, 2002 Ben Wing.
;; Author: Ben Wing
@@ -81,6 +81,34 @@
(start-process name buffer shell-file-name shell-command-switch
(mapconcat #'identity args " ")))
+(defun call-process-shell-command (command &optional infile buffer display
+ &rest args)
+ "Execute the shell command COMMAND synchronously in separate process.
+The remaining arguments are optional.
+The program's input comes from file INFILE (nil means `/dev/null').
+Insert output in BUFFER before point; t means current buffer;
+ nil for BUFFER means discard it; 0 means discard and don't wait.
+BUFFER can also have the form (REAL-BUFFER STDERR-FILE); in that case,
+REAL-BUFFER says what to do with standard output, as above,
+while STDERR-FILE says what to do with standard error in the child.
+STDERR-FILE may be nil (discard standard error output),
+t (mix it with ordinary output), or a file name string.
+
+Fourth arg DISPLAY non-nil means redisplay buffer as output is inserted.
+Remaining arguments are strings passed as additional arguments for COMMAND.
+Wildcards and redirection are handled as usual in the shell.
+
+If BUFFER is 0, `call-process-shell-command' returns immediately with value nil.
+Otherwise it waits for COMMAND to terminate and returns a numeric exit
+status or a signal description string.
+If you quit, the process is killed with SIGINT, or SIGKILL if you quit again."
+ ;; We used to use `exec' to replace the shell with the command,
+ ;; but that failed to handle (...) and semicolon, etc.
+ (call-process shell-file-name
+ infile buffer display
+ shell-command-switch
+ (mapconcat 'identity (cons command args) " ")))
+
(defun process-synchronize-point (proc)
"Set the point(s) in buffer and stderr-buffer according to the process mark."
;; We need this because the documentation says to insert *BEFORE* point,
diff -r c6b1500299a7dc7c7fd5476d169a2478555dcf37 -r 965a9ddc915a9a300afedd57e4bd43d69ea4f2d0 man/ChangeLog
--- a/man/ChangeLog
+++ b/man/ChangeLog
@@ -1,3 +1,8 @@
+2012-10-13 Mats Lidell <matsl(a)xemacs.org>
+
+ * lispref/processes.texi (Synchronous Processes): New function
+ call-process-shell-command.
+
2012-09-18 Mats Lidell <matsl(a)xemacs.org>
* lispref/windows.texi (Vertical Scrolling): Added
diff -r c6b1500299a7dc7c7fd5476d169a2478555dcf37 -r 965a9ddc915a9a300afedd57e4bd43d69ea4f2d0 man/lispref/processes.texi
--- a/man/lispref/processes.texi
+++ b/man/lispref/processes.texi
@@ -309,6 +309,13 @@
@end smallexample
@end defun
+@defun call-process-shell-command command &optional infile destination display &rest args
+This function executes the shell command @var{command} synchronously.
+The final arguments @var{args} are additional arguments to add at the
+end of @var{command}. The other arguments are handled as in
+@code{call-process}.
+@end defun
+
@node MS-DOS Subprocesses
@section MS-DOS Subprocesses
diff -r c6b1500299a7dc7c7fd5476d169a2478555dcf37 -r 965a9ddc915a9a300afedd57e4bd43d69ea4f2d0 tests/ChangeLog
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,8 @@
+2012-10-13 Mats Lidell <matsl(a)xemacs.org>
+
+ * automated/process-tests.el: Simple test cases for
+ call-process-shell-command.
+
2012-09-02 Aidan Kehoe <kehoea(a)parhasard.net>
* automated/regexp-tests.el:
diff -r c6b1500299a7dc7c7fd5476d169a2478555dcf37 -r 965a9ddc915a9a300afedd57e4bd43d69ea4f2d0 tests/automated/process-tests.el
--- a/tests/automated/process-tests.el
+++ b/tests/automated/process-tests.el
@@ -1,4 +1,4 @@
-;; Copyright (C) 2011 Free Software Foundation, Inc.
+;; Copyright (C) 2011, 2012 Free Software Foundation, Inc.
;; Author: Mats Lidell <matsl(a)xemacs.org>
;; Maintainer:
@@ -67,4 +67,18 @@
(with-current-buffer "Output buffer"
(goto-char (point-min))
(Assert (looking-at "foobar")))
-)
+ )
+
+;; call-process-shell-command
+(when (equal system-type 'linux)
+ (setenv "LANG" "C")
+
+ ;; Output one line
+ (Assert (= 0 (call-process-shell-command "echo hello")))
+
+ ;; Output to stderr but no error buffer
+ (Assert (= 0 (call-process-shell-command "echo -e \"barefoot\nfoobar\n\" 1>&2" nil "Output buffer")))
+ (with-current-buffer "Output buffer"
+ (goto-char (point-min))
+ (Assert (looking-at "barefoot\n")))
+ )
Repository URL: https://bitbucket.org/xemacs/xemacs/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://lists.xemacs.org/mailman/listinfo/xemacs-patches