Commit graph

57 commits

Author SHA1 Message Date
Akib Azmain Turja
12a5fb72b2
; * eat.el (eat--t-term): Fix 'params' docstring 2022-12-10 13:27:58 +06:00
Akib Azmain Turja
978aff9166
Implement terminal parameters
* eat.el (eat--t-term): New slot: 'params'.
* eat.el (eat-term-parameter): New function and generalized
variable.
* eat.el (eat-set-term-parameter): New function.
2022-12-10 02:14:28 +06:00
Akib Azmain Turja
f047b2d283
Fix terminal color reporting in text terminals
* eat.el (eat--t-report-foreground-color): Fix foreground color
reporting in text terminals.
* eat.el (eat--t-report-background-color): Fix background color
reporting in text terminals.
2022-12-09 20:44:08 +06:00
Akib Azmain Turja
b996bffa4b
Break combined 'setq'/'setf'/'setq-local's
When giving more than two arguments to 'setq', it becomes hard
to figure out what is assigned to what.  As the number of
argument increases, the readablity of code decreases.  This is
also true for 'setq-local'.  For 'setf', the problem is even
greater, unlike 'setq', all arguments to 'setf' look the same.

* eat.el (eat--t-reset, eat--t-write, eat--t-save-cur)
(eat--t-restore-cur, eat--t-enable-alt-disp)
(eat--t-disable-alt-disp, eat--t-change-scroll-region)
(eat--t-set-sgr-params, eat--t-manipulate-selection)
(eat--t-resize, eat--blink-start-timers, eat-blink-mode)
(eat--cursor-blink-mode, eat--set-cursor, eat-self-input)
(eat-mode, eat-exec, eat--eshell-setup-proc-and-term)
(eat--eshell-cleanup, eat--eshell-adjust-make-process-args)
(eat--eshell-local-mode, eat--eshell-exec-visual)
(eat--trace-exec, eat--trace-eshell-adjust-make-process-args)
(eat--trace-replay-eval, eat-trace-replay, eat-trace--cleanup):
Break combined 'setq'/'setf'/'setq-local's.
2022-12-08 18:04:56 +06:00
Akib Azmain Turja
2207109d24
; * eat.el (eat-term-color-.*): Fix docstring 2022-12-08 17:36:54 +06:00
Akib Azmain Turja
980265ac05
Don't 'cd' as root when using 'sudo' from Tramp
* eat.el (eat--eshell-setup-proc-and-term): Don't set
'eat--eshell-invocation-directory'.
* eat.el (eat--eshell-update-cwd): New function.
* eat.el (eat--eshell-local-mode): Call
'eat--eshell-update-cwd' when enabling the mode and add it to
'eshell-directory-change-hook' to keep track of Eshell's
working directory.
2022-12-08 17:00:12 +06:00
Akib Azmain Turja
856d429f2d
Fix prompt annotation bug trigger when shell exits
* eat.el (eat--correct-shell-prompt-mark-overlays): Make sure
'eat--terminal' is non-nil.
* eat.el (eat--sentinel): Cancel timers, correct shell prompt
annotations for the final time, reset shell prompt annotation
related local variables.
2022-12-08 15:58:20 +06:00
Akib Azmain Turja
58fd1b1196
Synchronize scrolling only when point is on cursor
* eat.el (eat--adjust-process-window-size): Synchronize
scrolling only when point is on cursor.
2022-12-07 15:38:47 +06:00
Akib Azmain Turja
ebc77efd0f
Escape control characters in trace output
* eat.el (eat--trace-log): Escape control
characters (codepoints from 0 to 31) in trace output.
2022-12-07 15:34:14 +06:00
Akib Azmain Turja
e6a7deafd0
Auto update 'eat-term-shell-integration-directory'
* eat.el: Auto update 'eat-term-shell-integration-directory' if
not modified.
2022-12-07 13:17:37 +06:00
Akib Azmain Turja
e05931d7e9
Document annotation correction delay user option
* eat.texi (Performance Tuning): Document the purpose and the
use of 'eat-shell-prompt-annotation-correction-delay' user
option.
2022-12-07 12:00:41 +06:00
Akib Azmain Turja
2ea84e0a34
Don't accept 'nil' as annotation correction delay
* eat.el (eat-shell-prompt-annotation-correction-delay): Don't
accept 'nil'.
* eat.el (eat--process-output-queue): Don't accept value 'nil'
for 'eat-shell-prompt-annotation-correction-delay'.
2022-12-07 11:17:20 +06:00
Akib Azmain Turja
a65b7bc064
Rename some symbols to reflect their purposes
* eat.el (eat-shell-prompt-annotation-delay): Rename to
'eat-shell-prompt-annotation-correction-delay'.
* eat.el (eat--update-shell-prompt-mark-overlays): Rename to
'eat--correct-shell-prompt-mark-overlays'.
* eat.el (eat--shell-prompt-annotation-update-timer): Rename to
'eat--shell-prompt-annotation-correction-timer'.
* eat.el (eat-mode, eat--process-output-queue, eat--filter):
Update references to renamed symbols.
2022-12-07 11:06:44 +06:00
Akib Azmain Turja
62a09caef1
* eat.el (eat--t-term): Fix initial value of 'cwd' 2022-12-07 00:11:29 +06:00
Akib Azmain Turja
b42687f146
Fix prompt navigation when annotation is disabled
* eat.el (eat--pre-prompt): Always set
'eat--shell-prompt-begin'.
* eat.el (eat--post-prompt): Always put special prompt end
marking text property.
2022-12-06 22:57:47 +06:00
Akib Azmain Turja
2c6afa4dc0
Add shell prompt navigation commands
* eat.el (eat--post-prompt): Add special text property on the
last character of shell prompt.
* eat.el (eat-previous-shell-prompt, eat-next-shell-prompt):
New command.
* eat.el (eat-mode-map): Bind 'eat-previous-shell-prompt' and
'eat-next-shell-prompt' to 'C-c C-p' and 'C-c C-n'
respectively.
2022-12-06 22:03:33 +06:00
Akib Azmain Turja
a04999011f
Annotate shell prompts
* eat.el (eat-enable-shell-prompt-annotation)
(eat-shell-prompt-annotation-position)
(eat-shell-prompt-annotation-running-margin-indicator)
(eat-shell-prompt-annotation-success-margin-indicator)
(eat-shell-prompt-annotation-failure-margin-indicator)
(eat-shell-prompt-annotation-delay): New user option.
* eat.el (eat-shell-prompt-annotation-running)
(eat-shell-prompt-annotation-success)
(eat-shell-prompt-annotation-failure): New face.
* eat.el (eat--shell-command-status, eat--shell-prompt-begin)
(eat--shell-prompt-mark, eat--shell-prompt-mark-overlays): New
variable.
* eat.el (eat--pre-prompt, eat--post-prompt)
(eat--update-shell-prompt-mark-overlays, eat--pre-cmd)
(eat--set-cmd-status): New function.
* eat.el (eat-mode): Make 'eat--shell-command-status',
'eat--shell-prompt-begin', 'eat--shell-prompt-mark',
'eat--shell-prompt-mark-overlays' and
'eat--shell-prompt-annotation-update-timer' local.  Set margin
width if shell prompt annotation is enabled.
* eat.el (eat--shell-prompt-annotation-update-timer): New
variable.
* eat.el (eat--process-output-queue): Call or schedule
'eat--update-shell-prompt-mark-overlays' call.
* eat.el (eat--filter): Cancel timer
'eat--shell-prompt-annotation-update-timer'.
* eat.el (eat-exec): Set prompt start & end and command start &
end functions.
2022-12-06 21:30:01 +06:00
Akib Azmain Turja
b4d07cb474
Add shell commands run in Eat to Emacs history
* eat.el (eat-enable-shell-command-history): New user option.
* eat.el (eat--set-cmd): New function.
* eat.el (eat-exec, eat--eshell-setup-proc-and-term): Call
'eat--set-cmd' when the shell reports the command being run.
2022-12-06 13:22:43 +06:00
Akib Azmain Turja
9caa496e45
Tighter shell integration
* eat.el (eat--t-term): New slots: 'prompt-start-fn',
'prompt-end-fn', 'cont-prompt-start-fn', 'cont-prompt-end-fn',
'set-cmd-fn', 'cmd-start-fn', 'cmd-finish-fn'
* eat.el (eat--t-set-cwd): Accept three arguments in two
different formats.
* eat.el (eat--t-prompt-start, eat--t-prompt-end)
(eat--t-cont-prompt-start, eat--t-cont-prompt-end)
(eat--t-set-cmd, eat--t-cmd-start, eat--t-cmd-finish): New
function.
* eat.el (eat--t-handle-output): Accept Eat's own
OSC 51 ; e ; ... ST sequences.
* eat.el (eat-term-prompt-start-function)
(eat-term-prompt-end-function)
(eat-term-continuation-prompt-start-function)
(eat-term-continuation-prompt-end-function)
(eat-term-set-cmd-function, eat-term-cmd-start-function)
(eat-term-cmd-finish-function): New generalized variable.
* integration/bash (__eat_current_command, __eat_exit_status):
New variable.
* integration/bash (__eat_prompt_command): Send exit status of
last command, if applicable.  Use Eat specific sequence to
report working directory.  Set title.
* integration/bash (__eat_preexec): Report current command and
execution start.
* integration/bash (__eat_before_prompt_command): Set
'__eat_exit_status' to the exit status of the last command.
* integration/bash (__eat_prompt_start, __eat_prompt_end)
(__eat_continuation_start, __eat_continuation_end): New
variable, used as constant only to make the code more readable.
* integration/bash (__eat_enable_integration): Wrap 'PS1' and
'PS2'.  Don't set title from 'PS1'.
2022-12-06 00:21:48 +06:00
Akib Azmain Turja
d35864ca6b
Calculate the number of lines on window properly
* eat.el (eat-exec, eat--eshell-setup-proc-and-term)
(eat--eshell-adjust-make-process-args)
(eat--eshell-synchronize-scroll): Calculate the number of
available lines on window properly.
2022-12-04 22:49:56 +06:00
Akib Azmain Turja
775328790c
Remap 'insert-char' to read and input a character
* eat.el (eat-input-char): New function.
* eat.el (eat-semi-char-mode-map)
(eat-eshell-semi-char-mode-map): Remap 'insert-char' to
'eat-input-char'.
2022-12-04 19:32:14 +06:00
Akib Azmain Turja
a21e665120
Use full command as title in shell integration
* integration/bash (__eat_in_prompt_command): Rename to
'__eat_inhibit_preexec'.
* integration/bash (__eat_before_exec): Inhibit further
'__eat_preexec' calls until next prompt.
* integration/bash (__eat_preexec): Use 'history' to get the
real command typed by the user.
2022-12-04 18:43:06 +06:00
Akib Azmain Turja
a95ca85927
* eat.el: Fix bright faces face definitions 2022-12-04 16:42:34 +06:00
Akib Azmain Turja
55c7d21cef
Use more uniform names for tracer functions
* eat.el: Rename 'eat--eshell-trace-...' symbols to
'eat--trace-eshell-...'.
2022-12-03 11:18:28 +06:00
Akib Azmain Turja
d918dbae87
Add shell integration script for GNU Bash
* integration/bash: New file.
* eat.el (eat-term-shell-integration-directory): New variable.
Contains path to the directory containing the scripts,
automatically updated when Eat is updated.
* eat.el (eat-exec, eat-eshell-mode): New enviroment variable
'EAT_SHELL_INTEGRATION_DIR'.
* eat.texi (Shell Integration): New chapter.
* eat.texi (Directory Tracking): Refer to 'Shell Integration'.
2022-12-03 11:14:01 +06:00
Akib Azmain Turja
5f4f4a87d1
; * eat.el: Fix font face names. 2022-12-02 10:27:37 +06:00
Akib Azmain Turja
406d72b4b5
Refer to Info manual to setup directory tracking
* eat.el (eat-enable-directory-tracking): Refer to Info manual.
2022-12-01 02:01:11 +06:00
Akib Azmain Turja
eac1165a1a
Support directory tracking with OSC 7
* eat.el: Require 'url'.
* eat.el (eat-enable-directory-tracking): New user option.
* eat.el (eat--t-term): New slots: 'cwd' and 'set-cwd-fn'.
* eat.el (eat--t-set-cwd, eat-term-cwd): New function.
* eat.el (eat-term-set-cwd-function): New function and
generalized variable.
* eat.el (eat--t-handle-output): Handle OSC 7.
* eat.el (eat--set-cwd): New function.
* eat.el (eat-exec): Use 'eat--set-cwd' to change current
working directory.
* eat.el (eat--eshell-invocation-directory): New variable,
local in Eshell buffers when 'eat-eshell-mode' is enabled.
* eat.el (eat--eshell-setup-proc-and-term): Save the invocation
directory of process.
* eat.el (eat--eshell-cleanup): Revert working directory to
invocation directory.
* eat.el (eat--eshell-local-mode): When enabling, make
'eat--eshell-invocation-directory' local variable and kill when
disabling.
* eat-tests.el (eat-test-set-cwd): New test.
* eat.texi (Directory Tracking): New chapter.
2022-12-01 01:40:17 +06:00
Akib Azmain Turja
29a6ab9141
Fix byte-compilation warnings on Emacs 28
* eat.el (eat-term-input-event): Fix byte-compilation warnings
on Emacs 28, caused by calling 'posn-col-row' with two
arguments on Emacs >= 29, which is not available on Emacs 28.
2022-11-30 22:40:11 +06:00
Akib Azmain Turja
2b7dccd741
* eat.el: Use loop to define color and font faces 2022-11-30 17:26:26 +06:00
Akib Azmain Turja
16d9a5074f
; Bump version to 0.1.1
* eat.el:
* eat.texi:
Bump version.
* ChangeLog: Add ChangeLog.
2022-11-30 13:09:02 +06:00
Akib Azmain Turja
0cf617d60e
Fix compatibility issues with Emacs 28
* eat.el: Require 'subr-x'.
* eat.el (eat-yank, eat-yank-pop): Pass three arguments to
'mapconcat'.
* eat.el (eat--eshell-term-name): New function.
* eat.el (eat-eshell-mode): Use 'eat--eshell-term-name' instead
of using 'eat-term-name' directly.
* eat.el (eat-eshell-mode) [(< emacs-major-version 29)]: Use
'eshell-last-async-proc' instead of 'eshell-last-async-procs'.
* eat.el (eat--eshell-adjust-make-process-args)
[(< emacs-major-version 29)]: Don't check and set ':filter' and
':sentinel' of 'make-process' argument plist.  Set process
filter and sentinel from 'eshell-exec-hook'.
* eat.el (eat--eshell-adjust-make-process-args): Call
'eat--eshell-setup-proc-and-term' from 'eshell-exec-hook', not
just after 'make-process'.
2022-11-30 12:29:05 +06:00
Akib Azmain Turja
1b2b7aee26
Bump version to 0.1
* eat.el:
* eat.texi:
Bump version.
2022-11-29 01:39:25 +06:00
Akib Azmain Turja
59c0745e75
Don't put 'error' as the only then part of 'if'
* eat.el (eat-semi-char-mode, eat-char-mode): Don't put 'error'
as only then part of 'if'.
2022-11-29 01:38:41 +06:00
Akib Azmain Turja
10d9f3cb56
Use 'mapc' to make & kill multiple local variables
* eat.el (eat-blink-mode, eat--cursor-blink-mode, eat-mode)
(eat--eshell-local-mode, eat-trace-replay-mode): Use 'mapc' to
make & kill multiple local variables.
2022-11-29 01:04:36 +06:00
Akib Azmain Turja
528bfe424d
Put declare-function and defvar outside functions
* eat.el (eat--flip-slow-blink-state)
(eat--flip-fast-blink-state, eat-blink-mode)
(eat--eshell-output-filter, eat--eshell-cleanup)
(eat--eshell-process-output-queue, eat--eshell-sentinel)
(eat-eshell-mode, eat--eshell-visual-sentinel)
(eat--eshell-exec-visual, eat-eshell-visual-command-mode)
(eat-project): Move 'declare-function's and 'defvar's outside.
2022-11-29 00:48:04 +06:00
Akib Azmain Turja
86e247137b
Use 'vector' directly instead of backquote
* eat.el (eat-term-make-keymap): Use 'vector' directly instead
of backquote.
2022-11-29 00:40:51 +06:00
Akib Azmain Turja
c19cf68b28
* eat.el (eat-term-make-keymap): Use 'cl-flet' 2022-11-29 00:37:47 +06:00
Akib Azmain Turja
5ce98430e8
Use more readable '?\C-\s' instead of '?\C-\ '
* eat.el (eat-term-input-event, eat-term-make-keymap): Use more
readable '?\C-\s' instead of '?\C-\ '.
2022-11-29 00:31:34 +06:00
Akib Azmain Turja
31f93da3fd
* eat.el (eat-mode): Fix char mode 'help-echo' 2022-11-29 00:28:03 +06:00
Akib Azmain Turja
9a9d9165f2
* eat.el (eat--bell): Use 'ding' instead of 'beep' 2022-11-29 00:22:39 +06:00
Akib Azmain Turja
dc99739fb8
* eat.el (eat--trace-exec): Use "-*- mode: MD -*-" 2022-11-29 00:18:28 +06:00
Akib Azmain Turja
0e82988d6f
Use 'setf' + 'plist-get' instead of 'plist-put'
* eat.el (eat--eshell-adjust-make-process-args): Use (setf (plist-get
...) ...) instead of 'plist-put' without taking the result, which is
not guaranteed to always work.
2022-11-29 00:17:15 +06:00
Akib Azmain Turja
a736f08ea9
Prefer 'and-let*' and 'when-let*' over 'when-let'
* eat.el (eat--t-set-sgr-params): Use 'and-let*' instead of 'when-let'
for side-effect free 'when-let'.
* eat.el (eat--flip-cursor-blink-state, eat--synchronize-scroll)
(eat-exec, eat--eshell-setup-proc-and-term)
(eat--eshell-synchronize-scroll, eat--eshell-visual-sentinel)
(eat--trace-replay-eval-next): Use 'when-let*' instead of 'when-let'
for 'when-let's with side-effect.
2022-11-28 23:22:52 +06:00
Akib Azmain Turja
2dd4e42773
Prefer 'pcase-exhaustive' over 'pcase'
* eat.el (eat--t-erase-in-line, eat--t-erase-in-disp)
(eat--t-set-mouse-mode, eat--t-send-device-attrs)
(eat--t-handle-output, eat-term-input-event)
(eat--manipulate-kill-ring, eat--trace-replay-eval):
Prefer 'pcase-exhaustive' over 'pcase'.
2022-11-28 23:19:56 +06:00
Akib Azmain Turja
b36f923919
* eat.el (eat--t-change-charset): Assert argument 2022-11-28 22:13:06 +06:00
Akib Azmain Turja
9a5bd15866
Combine multiple setq/setf/setq-local into one
* eat.el (eat--t-reset, eat--t-goto, eat--t-write)
(eat--t-save-cur, eat--t-enable-alt-disp)
(eat--t-change-scroll-region, eat--t-set-sgr-params)
(eat--t-manipulate-selection, eat--t-handle-output)
(eat--t-resize, eat--flip-slow-blink-state)
(eat--flip-fast-blink-state, eat-blink-mode)
(eat--cursor-blink-mode, eat--set-cursor, eat-self-input)
(eat-mode, eat-exec, eat--eshell-setup-proc-and-term)
(eat--eshell-cleanup, eat--eshell-local-mode)
(eat--eshell-exec-visual, eat--trace-exec)
(eat--eshell-trace-adjust-make-process-args)
(eat--trace-replay-eval, eat-trace-replay, eat-trace--cleanup):
Combine multiple setq/setf/setq-local into one wherever
possible.
2022-11-28 21:54:55 +06:00
Akib Azmain Turja
bc4bd45fa6
Avoid copying STR to the extent possible
* eat.el (eat--t-write): Take two more optional arguments BEG
and END to avoid copying STR multiple times unneccessarily.
2022-11-28 20:50:58 +06:00
Akib Azmain Turja
9d14bbeaa5
Support multi-column characters properly
* eat.el (eat--t-write): Use 'char-width' instead of the
unpredictable 'string-width' to support multi-column characters
properly.
2022-11-28 19:37:17 +06:00
Akib Azmain Turja
6a94082eff
Use hash table to convert from charset
* eat.el (eat--t-dec-line-drawing-chars): New constant
containing the hash table.
* eat.el (eat--t-write): Use hash-table instead alist while
converting from DEC Line Drawing charset.
2022-11-28 18:48:38 +06:00