diff options
| author | Eli Zaretskii | 2016-05-07 12:16:27 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2016-05-07 12:16:27 +0300 |
| commit | 4ffec91aa1fe668609f460cf6377644597c23306 (patch) | |
| tree | 4fe9756b816ca269d3fb520b1f3719dad3696673 | |
| parent | dc662713e235c9c55c71636168af7e14519f180d (diff) | |
| download | emacs-4ffec91aa1fe668609f460cf6377644597c23306.tar.gz emacs-4ffec91aa1fe668609f460cf6377644597c23306.zip | |
Document automatic adjustment of process' logical window dimensions
* doc/lispref/processes.texi (Process Buffers): Document
'set-process-window-size' and
'window-adjust-process-window-size-function'.
* etc/NEWS: Mention the new functionality and variable.
* src/process.c (Fset_process_window_size): Improve the doc string.
| -rw-r--r-- | doc/lispref/processes.texi | 52 | ||||
| -rw-r--r-- | etc/NEWS | 8 | ||||
| -rw-r--r-- | src/process.c | 4 |
3 files changed, 63 insertions, 1 deletions
diff --git a/doc/lispref/processes.texi b/doc/lispref/processes.texi index f660b159386..03ae1f04349 100644 --- a/doc/lispref/processes.texi +++ b/doc/lispref/processes.texi | |||
| @@ -1381,6 +1381,58 @@ Killing the process's buffer deletes the process, which kills the | |||
| 1381 | subprocess with a @code{SIGHUP} signal (@pxref{Signals to Processes}). | 1381 | subprocess with a @code{SIGHUP} signal (@pxref{Signals to Processes}). |
| 1382 | @end defun | 1382 | @end defun |
| 1383 | 1383 | ||
| 1384 | If the process's buffer is displayed in a window, your Lisp program | ||
| 1385 | may wish telling the process the dimensions of that window, so that | ||
| 1386 | the process could adapt its output to those dimensions, much as it | ||
| 1387 | adapts to the screen dimensions. The following functions allow to | ||
| 1388 | communicate this kind of information to processes; however, not all | ||
| 1389 | systems support the underlying functionality, so it is best to provide | ||
| 1390 | fallbacks, e.g., via command-line arguments or environment variables. | ||
| 1391 | |||
| 1392 | @defun set-process-window-size process height width | ||
| 1393 | Tell @var{process} that its logical window size has dimensions | ||
| 1394 | @var{width} by @var{height}, in character units. If this function | ||
| 1395 | succeeds in communicating this information to the process, it returns | ||
| 1396 | @code{t}; otherwise it returns @code{nil}. | ||
| 1397 | @end defun | ||
| 1398 | |||
| 1399 | When windows that display buffers associated with process change their | ||
| 1400 | dimensions, the affected processes should be told about these changes. | ||
| 1401 | By default, when the window configuration changes, Emacs will | ||
| 1402 | automatically call @code{set-process-window-size} on behalf of every | ||
| 1403 | process whose buffer is displayed in a window, passing it the smallest | ||
| 1404 | dimensions of all the windows displaying the process's buffer. This | ||
| 1405 | works via @code{window-configuration-change-hook} (@pxref{Window | ||
| 1406 | Hooks}), which is told to invoke the function that is the value of | ||
| 1407 | the variable @code{window-adjust-process-window-size-function} for | ||
| 1408 | each process whose buffer is displayed in at least one window. You | ||
| 1409 | can customize this behavior by setting the value of that variable. | ||
| 1410 | |||
| 1411 | @defopt window-adjust-process-window-size-function | ||
| 1412 | The value of this variable should be a function of two arguments: a | ||
| 1413 | process and the list of windows displaying the process's buffer. When | ||
| 1414 | the function is called, the process's buffer is the current buffer. | ||
| 1415 | The function should return a cons cell @w{@code{(@var{width} | ||
| 1416 | . @var{height})}} that describes the dimensions of the logical process | ||
| 1417 | window to be passed via a call to @code{set-process-window-size}. The | ||
| 1418 | function can also return @code{nil}, in which case Emacs will not call | ||
| 1419 | @code{set-process-window-size} for this process. | ||
| 1420 | |||
| 1421 | Emacs supplies two predefined values for this variable: | ||
| 1422 | @code{window-adjust-process-window-size-smallest}, which returns the | ||
| 1423 | smallest of all the dimensions of the windows that display a process's | ||
| 1424 | buffer; and @code{window-adjust-process-window-size-largest}, which | ||
| 1425 | returns the largest dimensions. For more complex strategies, write | ||
| 1426 | your own function. | ||
| 1427 | |||
| 1428 | This variable can be buffer-local. | ||
| 1429 | @end defopt | ||
| 1430 | |||
| 1431 | If the process has the @code{adjust-window-size-function} property | ||
| 1432 | (@pxref{Process Information}), its value overrides the global and | ||
| 1433 | buffer-local values of | ||
| 1434 | @code{window-adjust-process-window-size-function}. | ||
| 1435 | |||
| 1384 | @node Filter Functions | 1436 | @node Filter Functions |
| 1385 | @subsection Process Filter Functions | 1437 | @subsection Process Filter Functions |
| 1386 | @cindex filter function | 1438 | @cindex filter function |
| @@ -1588,6 +1588,14 @@ process filter, sentinel, etc., through keyword arguments (similar to | |||
| 1588 | 'make-network-process'). | 1588 | 'make-network-process'). |
| 1589 | 1589 | ||
| 1590 | +++ | 1590 | +++ |
| 1591 | ** Subprocesses are automatically told about changes in window dimensions | ||
| 1592 | The new option 'window-adjust-process-window-size-function' controls | ||
| 1593 | how subprocesses are told to adapt their logical window sizes to | ||
| 1594 | changes in the Emacs window configuration. Its default value calls | ||
| 1595 | 'set-process-window-size' with the smallest dimensions of all the | ||
| 1596 | windows that display the subprocess's buffer. | ||
| 1597 | |||
| 1598 | +++ | ||
| 1591 | ** A new function 'directory-files-recursively' returns all matching | 1599 | ** A new function 'directory-files-recursively' returns all matching |
| 1592 | files (recursively) under a directory. | 1600 | files (recursively) under a directory. |
| 1593 | 1601 | ||
diff --git a/src/process.c b/src/process.c index 2c758a4c9a7..14d7b6df1c3 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -1108,7 +1108,9 @@ See `set-process-sentinel' for more info on sentinels. */) | |||
| 1108 | 1108 | ||
| 1109 | DEFUN ("set-process-window-size", Fset_process_window_size, | 1109 | DEFUN ("set-process-window-size", Fset_process_window_size, |
| 1110 | Sset_process_window_size, 3, 3, 0, | 1110 | Sset_process_window_size, 3, 3, 0, |
| 1111 | doc: /* Tell PROCESS that it has logical window size HEIGHT and WIDTH. */) | 1111 | doc: /* Tell PROCESS that it has logical window size WIDTH by HEIGHT. |
| 1112 | Value is t if PROCESS was successfully told about the window size, | ||
| 1113 | nil otherwise. */) | ||
| 1112 | (Lisp_Object process, Lisp_Object height, Lisp_Object width) | 1114 | (Lisp_Object process, Lisp_Object height, Lisp_Object width) |
| 1113 | { | 1115 | { |
| 1114 | CHECK_PROCESS (process); | 1116 | CHECK_PROCESS (process); |