Skip to content

Commit 5321d1b

Browse files
committed
Wire evil-ghostel into byte-compile and lint
`extensions/evil-ghostel/evil-ghostel.el' was never byte-compiled by `make all' — only `lisp/' files were in $(ELC), and package-lint only ran on `lisp/ghostel.el'. MELPA's stricter sandbox caught warnings ours didn't. - Add `extensions/evil-ghostel/evil-ghostel.elc' to $(ELC); split the pattern rule so `lisp/%.elc' compiles with `-L lisp' as before, and `extensions/evil-ghostel/%.elc' compiles with `-L $(EVIL_DIR) -L lisp -L extensions/evil-ghostel'. - Factor the evil clone into an order-only `$(EVIL_DIR)' target reused by both the new compile rule and `test-evil'. - Extend `package-lint' to also lint evil-ghostel.el. - Add a `docquotes' target mirroring melpazoid's regex check for back/front-quoted non-symbols, widened from melpazoid's `[A-Z]+' to `[A-Z_]+' so identifiers like INSIDE_EMACS aren't skipped. Wire into `lint'. - Add forward declarations: `evil-ghostel-mode', `ghostel--cursor-position', `ghostel--mode-enabled' in evil-ghostel.el; `ghostel--alt-screen-p' in ghostel-debug.el. Byte-compile now passes cleanly without the native module loaded. - Strip back/front quotes from env-var and keystroke names in docstrings (TERM, INSIDE_EMACS, EMACS_GHOSTEL_PATH, I/A) — those aren't top-level elisp symbols. - Fix a pre-existing parallel race: `test-evil' now depends on `build $(ELC)' (matching `test-native'). Without it, `make -j4 all' could start `test-evil' before `ghostel-module.dylib' existed, causing `void-function ghostel--new' failures intermittently.
1 parent e8eb2f8 commit 5321d1b

4 files changed

Lines changed: 48 additions & 15 deletions

File tree

Makefile

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ MELPAZOID_DIR ?= $(XDG_CACHE_HOME)/melpazoid
55
EVIL_DIR ?= $(XDG_CACHE_HOME)/evil
66

77
ELC := lisp/ghostel.elc lisp/ghostel-debug.elc lisp/ghostel-compile.elc \
8-
lisp/ghostel-eshell.elc
8+
lisp/ghostel-eshell.elc \
9+
extensions/evil-ghostel/evil-ghostel.elc
910

10-
.PHONY: all build test test-native test-all test-evil lint melpazoid melpazoid-ghostel melpazoid-evil-ghostel byte-compile bench bench-quick clean regen-terminfo
11+
.PHONY: all build test test-native test-all test-evil lint melpazoid melpazoid-ghostel melpazoid-evil-ghostel byte-compile docquotes bench bench-quick clean regen-terminfo
1112

1213
all: build test-all test-evil lint
1314

@@ -18,9 +19,18 @@ build:
1819
# Make's timestamp tracking keeps the byte-compiled files in sync, so
1920
# test targets never load stale .elc (Emacs prefers .elc over .el
2021
# even when the source is newer, which silently masks edits).
21-
%.elc: %.el
22+
lisp/%.elc: lisp/%.el
2223
$(EMACS) --batch -Q -L lisp --eval "(setq byte-compile-error-on-warn t)" -f batch-byte-compile $<
2324

25+
# Extension packages depend on third-party libraries; reuse the evil
26+
# checkout that `test-evil' manages.
27+
$(EVIL_DIR):
28+
git clone --depth 1 https://github.com/emacs-evil/evil.git "$@"
29+
30+
extensions/evil-ghostel/%.elc: extensions/evil-ghostel/%.el | $(EVIL_DIR)
31+
$(EMACS) --batch -Q -L "$(EVIL_DIR)" -L lisp -L extensions/evil-ghostel \
32+
--eval "(setq byte-compile-error-on-warn t)" -f batch-byte-compile $<
33+
2434
test: $(ELC)
2535
$(EMACS) --batch -Q -L lisp -l ert -l test/ghostel-test.el -f ghostel-test-run-elisp
2636

@@ -29,23 +39,20 @@ test-native: build $(ELC)
2939

3040
test-all: test test-native
3141

32-
test-evil:
33-
@if [ ! -d "$(EVIL_DIR)" ]; then \
34-
git clone --depth 1 https://github.com/emacs-evil/evil.git "$(EVIL_DIR)"; \
35-
fi
42+
test-evil: build $(ELC) | $(EVIL_DIR)
3643
$(EMACS) --batch -Q -L "$(EVIL_DIR)" -L lisp -L extensions/evil-ghostel \
3744
-l ert -l test/evil-ghostel-test.el -f evil-ghostel-test-run
3845

3946
byte-compile: $(ELC)
4047

41-
lint: byte-compile package-lint checkdoc
48+
lint: byte-compile package-lint checkdoc docquotes
4249

4350
package-lint:
4451
$(EMACS) --batch -Q \
4552
--eval "(package-initialize)" \
4653
--eval "(require 'package-lint)" \
4754
-f package-lint-batch-and-exit \
48-
lisp/ghostel.el
55+
lisp/ghostel.el extensions/evil-ghostel/evil-ghostel.el
4956

5057
checkdoc:
5158
$(EMACS) --batch -Q \
@@ -64,6 +71,26 @@ checkdoc:
6471
(message \"%s\" (buffer-string))))) \
6572
(unless ok (kill-emacs 1)))"
6673

74+
# Mirrors melpazoid's "Only use back/front quotes to link to top-level
75+
# elisp symbols" check, widened to also catch identifiers with
76+
# underscores like INSIDE_EMACS — env-var and macro-style names that
77+
# melpazoid's stricter [A-Z]+ regex skips.
78+
docquotes:
79+
$(EMACS) --batch -Q \
80+
--eval "(let ((ok t)) \
81+
(dolist (f '(\"lisp/ghostel.el\" \"lisp/ghostel-debug.el\" \"lisp/ghostel-compile.el\" \"lisp/ghostel-eshell.el\" \"extensions/evil-ghostel/evil-ghostel.el\")) \
82+
(with-temp-buffer \
83+
(insert-file-contents f) \
84+
(setq case-fold-search nil) \
85+
(goto-char (point-min)) \
86+
(while (re-search-forward \"\`[A-Z_]+'\" nil t) \
87+
(setq ok nil) \
88+
(message \"%s:%d:%d: Only use back/front quotes to link to top-level elisp symbols (%s)\" \
89+
f (line-number-at-pos) \
90+
(1+ (- (match-beginning 0) (line-beginning-position))) \
91+
(match-string 0))))) \
92+
(unless ok (kill-emacs 1)))"
93+
6794
melpazoid: melpazoid-ghostel melpazoid-evil-ghostel
6895

6996
melpazoid-ghostel:

extensions/evil-ghostel/evil-ghostel.el

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@
2727
(require 'evil)
2828
(require 'ghostel)
2929

30+
(declare-function ghostel--cursor-position "ghostel-module")
31+
(declare-function ghostel--mode-enabled "ghostel-module")
32+
33+
(defvar evil-ghostel-mode)
34+
3035
;; ---------------------------------------------------------------------------
3136
;; Customization
3237
;; ---------------------------------------------------------------------------
@@ -160,7 +165,7 @@ In alt-screen mode, defer to the terminal's cursor style."
160165

161166
(defvar evil-ghostel--sync-inhibit nil
162167
"When non-nil, skip arrow-key sync in the insert-state-entry hook.
163-
Set by the `I'https://github.com/`A' advice which send Home/End directly.")
168+
Set by the I/A advice which send Home/End directly.")
164169

165170
(defun evil-ghostel--insert-state-entry ()
166171
"Sync terminal cursor to Emacs point when entering `emacs-state'.

lisp/ghostel-debug.el

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@
3333
(require 'lisp-mnt)
3434
(require 'ghostel)
3535

36-
(declare-function ghostel--module-version "ghostel-module")
36+
(declare-function ghostel--alt-screen-p "ghostel-module")
3737
(declare-function ghostel--mode-enabled "ghostel-module")
38+
(declare-function ghostel--module-version "ghostel-module")
3839

3940
(defvar ghostel-debug--log-buffer nil
4041
"Buffer used for ghostel debug logging.")

lisp/ghostel.el

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,19 +131,19 @@ A list of \"KEY=VALUE\" strings, prepended to `process-environment'
131131
before spawning the shell. A bare \"KEY\" (no `=') unsets the variable.
132132
133133
For local spawns, entries here take precedence over ghostel's own
134-
variables (`TERM', `INSIDE_EMACS', `EMACS_GHOSTEL_PATH',
135-
shell-integration vars), so a user who sets `TERM' here wins — which
134+
variables (TERM, INSIDE_EMACS, EMACS_GHOSTEL_PATH,
135+
shell-integration vars), so a user who sets TERM here wins — which
136136
will also disable ghostel's shell integration if the chosen TERM
137137
breaks its assumptions.
138138
139139
Also honored via `dir-locals.el' for per-project overrides.
140140
141141
TRAMP caveats:
142142
- Entries with `=' are propagated to the remote shell.
143-
- `TERM' is always reset by TRAMP to `tramp-terminal-type' (see
143+
- TERM is always reset by TRAMP to `tramp-terminal-type' (see
144144
`tramp-handle-make-process'); overrides in `ghostel-environment'
145145
do not win remotely.
146-
- `INSIDE_EMACS' is rewritten by TRAMP via `tramp-inside-emacs',
146+
- INSIDE_EMACS is rewritten by TRAMP via `tramp-inside-emacs',
147147
which appends `,tramp:VER' to whatever value is in scope. For
148148
ghostel that means the remote shell sees `ghostel,tramp:VER'
149149
rather than the bare `ghostel' set locally — the leading

0 commit comments

Comments
 (0)