branch: externals/eev commit 30d2b10f85b0faef4171a7a25c7d4b5a67e5ded5 Author: Eduardo Ochs <eduardoo...@gmail.com> Commit: Eduardo Ochs <eduardoo...@gmail.com>
Added `eepitch-gdb-*' and `eepitch-slime-*'. --- ChangeLog | 25 ++++++++++++ VERSION | 4 +- eepitch.el | 118 +++++++++++++++++++++++++++++++++++++++++++++--------- eev-intro.el | 84 +++++++++++++++++++++++++++++++++----- eev-mode.el | 4 +- eev-testblocks.el | 105 +++++++++++++++++++++++++++++++++++++++++++++++- eev.el | 2 +- 7 files changed, 307 insertions(+), 35 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9719711767..9f2ff967b0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,28 @@ +2025-09-14 Eduardo Ochs <eduardoo...@gmail.com> + + * eev-mode.el (ee-kill-this-buffer): use `kill-current-buffer' + instead of `kill-this-buffer' because in recent versions of Emacs + `kill-this-buffer' can be invoked only from a menu or a tool bar. + + * eepitch.el (eepitch-gdb-start, eepitch-slime-kill) + (eepitch-slime-start, eepitch-slime-select): new functions. + +2025-09-13 Eduardo Ochs <eduardoo...@gmail.com> + + * eepitch.el (eepitch-slime-kill, eepitch-slime-select): new + functions. + + * eev-testblocks.el (ee-insert-test-lisp-mode-1): new function - a + variant that uses slime. + + * eev-intro.el (find-eepitch-intro): new section: "4. + Badly-behaved targets". + + * eepitch.el (ee-buffers-in-mode, ee-buffers-in-modes) + (ee-kill-buffers-in-mode, ee-kill-buffers-in-modes) + (find-ebuffer-in-mode, eepitch-gdb-kill, eepitch-gdb-select): new + functions. + 2025-08-31 Eduardo Ochs <eduardoo...@gmail.com> * eepitch.el (eepitch-b-source-buffer, eepitch-b-source-marker): diff --git a/VERSION b/VERSION index 232d7a0d16..db68a0ca01 100644 --- a/VERSION +++ b/VERSION @@ -1,2 +1,2 @@ -Mon Sep 1 01:07:03 GMT 2025 -Sun Aug 31 22:07:03 -03 2025 +Sun Sep 14 22:12:31 GMT 2025 +Sun Sep 14 19:12:31 -03 2025 diff --git a/eepitch.el b/eepitch.el index 7d71605107..33f876e152 100644 --- a/eepitch.el +++ b/eepitch.el @@ -19,7 +19,7 @@ ;; ;; Author: Eduardo Ochs <eduardoo...@gmail.com> ;; Maintainer: Eduardo Ochs <eduardoo...@gmail.com> -;; Version: 20250831 +;; Version: 20250914 ;; Keywords: e-scripts ;; ;; Latest version: <http://anggtwu.net/eev-current/eepitch.el> @@ -54,6 +54,9 @@ ;; «.eepitch-sly» (to "eepitch-sly") ;; «.badly-behaved» (to "badly-behaved") ;; «.eepitch-b» (to "eepitch-b") +;; «.ee-buffers-in-mode» (to "ee-buffers-in-mode") +;; «.eepitch-gdb» (to "eepitch-gdb") +;; «.eepitch-slime» (to "eepitch-slime") ;; ;; «.eepitch-langs» (to "eepitch-langs") ;; «.eepitch-langs-vterm» (to "eepitch-langs-vterm") @@ -1079,6 +1082,10 @@ If the mrepl doesn't start in 30 seconds this function yields an error." ;;; |___/ ;; ;; «badly-behaved» (to ".badly-behaved") +;; See: (find-eepitch-intro "4. Badly-behaved targets") +;; (find-eepitch-intro "4. Badly-behaved targets" "For example") +;; Warning: EXPERIMENTAL! BADLY DOCUMENTED! BADLY TESTED! +;; ;; Sometimes a target is so badly behaved - for example: Slime - that ;; I don't know how to write a sexp like this for it, ;; @@ -1096,22 +1103,14 @@ If the mrepl doesn't start in 30 seconds this function yields an error." ;; `(eepitch CODE)' as a black box that needs to be opened, that needs ;; to have its components run step by step by hand, and that the user ;; needs to select the right target buffer by running `M-x b' on it. -;; For example, in -;; -;; (eepitch-sbcl-slime) -;; (eepitch-kill) -;; (eepitch-sbcl-slime) +;; For example, in... ;; -;; each `eepitch-sbcl-slime' opens a temporary buffer that is "the -;; black box opened up". -;; -;; Note: this section only contains the core functions. -;; For a test, see: -;; http://anggtwu.net/elisp/2025-eepitch-b.el -;; (find-angg "elisp/2025-eepitch-b.el") +;; [I need to rewrite the rest!] ;; «eepitch-b» (to ".eepitch-b") +;; The basic functions for the support for badly-behaved targets. +;; (defvar eepitch-b-source-buffer "") (defvar eepitch-b-source-marker nil) @@ -1123,22 +1122,45 @@ If the mrepl doesn't start in 30 seconds this function yields an error." (interactive) (find-ebuffer eepitch-buffer-name)) +;; Test: +;; (eepitch-b-set-source) +;; (find-2a nil '(eepitch-b-show-source)) +;; (eepitch-b-set-source 2) +;; (find-2a nil '(eepitch-b-show-source)) +(defun eepitch-b-set-source (&optional n) + (interactive) + (setq eepitch-b-source-buffer (buffer-name)) + (setq eepitch-b-source-marker + (save-excursion + (if n (forward-line n)) + (point-marker)))) + +;; Test: +;; (eepitch-to-buffer "TODO") +;; (eepitch-b-set-source 3) +;; (eek "C-x 1") +;; (eepitch-b-show-source-and-target) (defun eepitch-b-show-source-and-target () (interactive) (find-2a '(eepitch-b-show-source) '(eepitch-b-show-target)) (message "%S -> %S" eepitch-b-source-buffer eepitch-buffer-name) (format "`%s' -> `%s'" eepitch-b-source-buffer eepitch-buffer-name)) -(defun eepitch-b-set-source () - (interactive) - (setq eepitch-b-source-buffer (buffer-name)) - (setq eepitch-b-source-marker (point-marker))) - (defun eepitch-b-set-target () + "An internal function used by `eepitch-set-source-and-M-x-b'." (interactive) (setq eepitch-buffer-name (buffer-name)) (eepitch-b-show-source-and-target)) +;; See: (find-eepitch-intro "4. Badly-behaved targets" "For example") +(defun eepitch-set-source-and-M-x-b (&optional n) + (interactive) + (eepitch-b-set-source n) + (defalias 'b 'eepitch-b-set-target) + (format "`M-x b' will set the eepitch target and return to `%s'" + eepitch-b-source-buffer)) + +;; Unused at the moment! (defun eepitch-b-insert () (interactive) (let* ((sexp `(eepitch-to-buffer ,eepitch-buffer-name)) @@ -1147,6 +1169,66 @@ If the mrepl doesn't start in 30 seconds this function yields an error." (insert line))) +;; «ee-buffers-in-mode» (to ".ee-buffers-in-mode") +;; These functions are used by some badly behaved targets - like gdb. +;; +(defun ee-buffers-in-mode (majormode) + (ee-buffers-in-modes (list majormode))) + +(defun ee-buffers-in-modes (majormodes) + (sort (cl-loop for b in (buffer-list) + if (member (with-current-buffer b major-mode) majormodes) + collect (buffer-name b)))) + +(defun ee-kill-buffers-in-mode (majormode) + (ee-kill-buffers-in-modes (list majormode))) + +(defun ee-kill-buffers-in-modes (majormodes) + (let* ((bufs (ee-buffers-in-modes majormodes))) + (cl-loop for b in bufs + do (ee-kill-buffer b)) + `(Buffers killed: ,(or bufs 'none)))) + +(defun find-ebuffer-in-mode (majormode &rest pos-spec-list) + "Similar to `find-ebuffer', but goes to the only buffer in MAJORMODE. +If the number of buffers with major mode MAJORMODE is not exactly one, +raise an error." + (let ((buffers (ee-buffers-in-mode majormode))) + (if (= 1 (length buffers)) + (apply 'find-ebuffer (car buffers) pos-spec-list) + (error "Error - buffers with major mode %s: %S" + majormode (or buffers 'none))))) + + +;; «eepitch-gdb» (to ".eepitch-gdb") +;; See: (find-eepitch-intro "4. Badly-behaved targets" "For example") + +(defun eepitch-gdb-kill () + (ee-kill-buffers-in-mode 'gud-mode)) + +(defun eepitch-gdb-start (command-line) + (eepitch-set-source-and-M-x-b 1) + (gdb command-line)) + +(defun eepitch-gdb-select () + (eepitch '(find-buffer-in-mode 'gud-mode))) + + +;; «eepitch-slime» (to ".eepitch-slime") +;; See: (find-eev "eev-testblocks.el" "slime") +;; +(defun eepitch-slime-kill () + (ee-kill-buffers-in-mode 'slime-repl-mode)) + +(defun eepitch-slime-start (command) + (eepitch-set-source-and-M-x-b 1) + (slime command)) + +(defun eepitch-slime-select () + (eepitch '(find-ebuffer-in-mode 'slime-repl-mode))) + + + ;;; _ diff --git a/eev-intro.el b/eev-intro.el index 4d650d2a75..70d22b92e7 100644 --- a/eev-intro.el +++ b/eev-intro.el @@ -19,7 +19,7 @@ ;; ;; Author: Eduardo Ochs <eduardoo...@gmail.com> ;; Maintainer: Eduardo Ochs <eduardoo...@gmail.com> -;; Version: 20250831 +;; Version: 20250913 ;; Keywords: e-scripts ;; ;; Latest version: <http://anggtwu.net/eev-current/eev-intro.el> @@ -6527,16 +6527,8 @@ This intro _complements_ the material in: (find-eev-quick-intro \"6. Controlling shell-like programs\") For a good visual introduction to eepitch, see this page: http://anggtwu.net/eepitch.html - -My video for the EmacsConf2019 has a simple demo of eepitch: - (find-eev2019hsubs \"15:38\") - (find-eev2019video \"15:38\") - https://www.youtube.com/watch?v=86yiRG8YJD0&t=956 - http://anggtwu.net/emacsconf2019.html - -This (old) video shows a demo like the one in section 1.3: - https://www.youtube.com/watch?v=Lj_zKC5BR64&t=16s -The relevant part is from t=16s to t=25s. +For some demos, see: + (find-eev-quick-intro \"6. Controlling shell-like programs\" \"[Video links:]\") In this intro we suppose that the reader knows what is a terminal and what is a shell. In Unix-like systems the terminal and the @@ -7154,6 +7146,76 @@ blocks in SmallTalk source files - but I haven't tried that yet. +4. Badly-behaved targets +======================== +In an eepitch block like this one + + (eepitch-shell) + (eepitch-kill) + (eepitch-shell) + +the first two red star lines are typically only used when we want to kill +a current shell target - if it exists - and then create a new one. + +For \"badly-behaved targets\" - I will explain the term precisely in the +next section - it is hard to define a function `eepitch-BBT' that would +work well enough in an eepitch block like this one, + + (eepitch-BBT) + (eepitch-kill) + (eepitch-BBT) + +and it is more practical to have a eepitch block with functions specific +for the target BBT, like this one: + + (eepitch-BBT-kill) + (eepitch-BBT-start) + (eepitch-BBT-select) + +but sometimes it is better to replace the middle red star line by +several lines, and make them remind us how to go back to our source +buffer. For example, here, + + (eepitch-gdb-kill) + To restart gdb: + (eepitch-set-source-and-M-x-b 2) + (gdb \"gdb -i=mi\") + (eepitch-gdb-select) + +the sexp `(gdb \"gdb -i=mi\")' asks some questions, messes up our window +configuration, and only leaves us at the target buffer after too many +keystrokes. + +Note that running the sexp `(eepitch-set-source-and-M-x-b 2)' prints +instructions in the echo area - it says: + + \"`M-x b' will set the eepitch target and return to `*(find-eepitch-intro)*'\" + +So after the `(gdb \"gdb -i=mi\")' finishes we need to run `M-x b'. The +sexp `(eepitch-set-source-and-M-x-b 2)' has saved the source buffer - +\"*(find-eepitch-intro)*\" - and the line that we need to return to, +that is 2 lines below the `(eepitch-set-source-and-M-x-b 2)' itself; +when we type `M-x b' Emacs interprets that as: this is the target +<b>uffer - go <b>ack to the source <b>uffer and use this window setup: + + _____________________ + | | | + | source | target | + | buffer | buffer | + | | | + |__________|__________| + + + + +4.1. What are badly-behaved targets? +------------------------------------ +(Examples: gdb, slime) +(Compare with Sly) + +UNFINISHED!!! +See: (find-eev \"eepitch.el\" \"badly-behaved\") + diff --git a/eev-mode.el b/eev-mode.el index 22922a90c5..2158b0424f 100644 --- a/eev-mode.el +++ b/eev-mode.el @@ -19,7 +19,7 @@ ;; ;; Author: Eduardo Ochs <eduardoo...@gmail.com> ;; Maintainer: Eduardo Ochs <eduardoo...@gmail.com> -;; Version: 20241013 +;; Version: 20250914 ;; Keywords: e-scripts ;; ;; Latest version: <http://anggtwu.net/eev-current/eev-mode.el> @@ -51,7 +51,7 @@ See: (find-eev-quick-intro \"3. Elisp hyperlinks\" \"go back\" \"`M-k'\") and: (find-eval-intro \"`M-k'\")" (interactive) (let ((kill-buffer-query-functions nil)) - (kill-this-buffer))) + (kill-current-buffer))) diff --git a/eev-testblocks.el b/eev-testblocks.el index 7bd89ccf7d..347b0961c9 100644 --- a/eev-testblocks.el +++ b/eev-testblocks.el @@ -19,7 +19,7 @@ ;; ;; Author: Eduardo Ochs <eduardoo...@gmail.com> ;; Maintainer: Eduardo Ochs <eduardoo...@gmail.com> -;; Version: 20250831 +;; Version: 20250913 ;; Keywords: e-scripts ;; ;; Latest version: <http://anggtwu.net/eev-current/eev-testblocks.el> @@ -44,6 +44,36 @@ ;; «.ee-insert-test» (to "ee-insert-test") ;; «.ee-insert-test-block» (to "ee-insert-test-block") ;; «.examples» (to "examples") +;; «.c-mode» (to "c-mode") +;; «.elixir-mode» (to "elixir-mode") +;; «.fennel-mode» (to "fennel-mode") +;; «.f90-mode» (to "f90-mode") +;; «.gnuplot-mode» (to "gnuplot-mode") +;; «.haskell-mode» (to "haskell-mode") +;; «.js-mode» (to "js-mode") +;; «.julia-mode» (to "julia-mode") +;; «.latex-mode» (to "latex-mode") +;; «.lisp» (to "lisp") +;; «.lisp-mode» (to "lisp-mode") +;; «.slime» (to "slime") +;; «.lua-mode» (to "lua-mode") +;; «.makefile-gmake» (to "makefile-gmake") +;; «.makefile-mode» (to "makefile-mode") +;; «.maxima-mode» (to "maxima-mode") +;; «.octave-mode» (to "octave-mode") +;; «.org-mode» (to "org-mode") +;; «.php-mode» (to "php-mode") +;; «.python-mode» (to "python-mode") +;; «.racket-mode» (to "racket-mode") +;; «.raku-mode» (to "raku-mode") +;; «.ruby-mode» (to "ruby-mode") +;; «.scheme-mode» (to "scheme-mode") +;; «.sml-mode» (to "sml-mode") +;; «.sh-mode» (to "sh-mode") +;; «.sql-mode» (to "sql-mode") +;; «.subed-vtt-mode» (to "subed-vtt-mode") +;; «.tcl-mode» (to "tcl-mode") +;; «.tuareg-mode» (to "tuareg-mode") @@ -93,6 +123,8 @@ If the major mode is `foo-mode' then this function calls ;; «examples» (to ".examples") ;; See: (find-eepitch-intro "3.1. `find-eeit-links'") + +;; «c-mode» (to ".c-mode") (defun ee-insert-test-c-mode () (interactive) (let* ((fnamec (buffer-name)) @@ -108,6 +140,8 @@ gcc -o {fname} {fnamec} */ "))))) + +;; «elixir-mode» (to ".elixir-mode") (defun ee-insert-test-elixir-mode () (interactive) (insert (ee-adjust-red-stars (format " @@ -120,6 +154,8 @@ c \"%s\" \"\"\" " (buffer-name))))) + +;; «fennel-mode» (to ".fennel-mode") (defun ee-insert-test-fennel-mode () (interactive) (let* ((fname (buffer-name)) @@ -134,6 +170,8 @@ c \"%s\" \") " stem))))) + +;; «f90-mode» (to ".f90-mode") (defun ee-insert-test-f90-mode () (interactive) (let* ((fullname (buffer-name)) @@ -149,6 +187,8 @@ c \"%s\" "))))) + +;; «gnuplot-mode» (to ".gnuplot-mode") (defun ee-insert-test-gnuplot-mode () (interactive) (insert (ee-adjust-red-stars (format " @@ -163,6 +203,8 @@ c \"%s\" " (buffer-name))))) + +;; «haskell-mode» (to ".haskell-mode") (defun ee-insert-test-haskell-mode () (interactive) (insert (ee-adjust-red-stars (format " @@ -175,6 +217,8 @@ c \"%s\" -} " (buffer-name))))) + +;; «js-mode» (to ".js-mode") (defun ee-insert-test-js-mode () (interactive) (insert (ee-adjust-red-stars (format " @@ -187,6 +231,8 @@ require(\"./%s\") */ " (buffer-name))))) + +;; «julia-mode» (to ".julia-mode") (defun ee-insert-test-julia-mode () (interactive) (insert (ee-adjust-red-stars (format " @@ -199,6 +245,8 @@ include(\"%s\") =# " (buffer-name))))) + +;; «latex-mode» (to ".latex-mode") (defun ee-insert-test-latex-mode () (interactive) (insert (ee-adjust-red-stars (format " @@ -214,6 +262,8 @@ include(\"%s\") " ; (buffer-name) )))) + +;; «lisp-mode» (to ".lisp-mode") (defun ee-insert-test-lisp-mode () (funcall (ee-intern "ee-insert-test-lisp-mode-%s" current-prefix-arg))) @@ -229,6 +279,25 @@ include(\"%s\") |# " (buffer-name))))) + +;; «slime» (to ".slime") +;; See: (find-eev "eepitch.el" "eepitch-slime") +(defun ee-insert-test-lisp-mode-1 () + (interactive) + (insert (ee-adjust-red-stars (format " +#| + (eepitch-slime-kill) + To restart Slime: + (eepitch-set-source-and-M-x-b 2) + (slime \"sbcl\") + (eepitch-slime-select) +(load \"%s\") + +|# +" (buffer-name))))) + + +;; «lua-mode» (to ".lua-mode") (defun ee-insert-test-lua-mode () (interactive) (let ((equals (make-string (or current-prefix-arg 0) ?=))) @@ -242,6 +311,8 @@ dofile \"%s\" --]%s] " equals (buffer-name) equals))))) + +;; «makefile-gmake» (to ".makefile-gmake") (defun ee-insert-test-makefile-gmake-mode () (interactive) (insert (ee-adjust-red-stars (format " @@ -256,6 +327,8 @@ dofile \"%s\" " (buffer-name))))) + +;; «makefile-mode» (to ".makefile-mode") (defun ee-insert-test-makefile-mode () (interactive) (insert (ee-adjust-red-stars (format " @@ -270,6 +343,8 @@ dofile \"%s\" " (buffer-name))))) + +;; «maxima-mode» (to ".maxima-mode") (defun ee-insert-test-maxima-mode () (interactive) (insert (ee-adjust-red-stars (format " @@ -282,6 +357,8 @@ load(\"%s\"); */ " (buffer-name))))) + +;; «octave-mode» (to ".octave-mode") (defun ee-insert-test-octave-mode () (interactive) (insert (ee-adjust-red-stars (format " @@ -294,6 +371,8 @@ run %s #} " (buffer-name))))) + +;; «org-mode» (to ".org-mode") (defun ee-insert-test-org-mode () (interactive) (insert (ee-adjust-red-stars " @@ -306,6 +385,8 @@ run %s "))) + +;; «php-mode» (to ".php-mode") (defun ee-insert-test-php-mode () (interactive) (insert (ee-adjust-red-stars (format " @@ -320,6 +401,8 @@ include '%s'; ?> " (buffer-name))))) + +;; «python-mode» (to ".python-mode") (defun ee-insert-test-python-mode () (interactive) (insert (ee-adjust-red-stars (format " @@ -332,6 +415,8 @@ exec(open(\"%s\").read(), globals()) \"\"\" " (buffer-name))))) + +;; «racket-mode» (to ".racket-mode") (defun ee-insert-test-racket-mode () (interactive) (insert (ee-adjust-red-stars (format " @@ -344,6 +429,8 @@ exec(open(\"%s\").read(), globals()) |# " (buffer-name))))) + +;; «raku-mode» (to ".raku-mode") (defun ee-insert-test-raku-mode () (interactive) (let ((libname @@ -365,6 +452,8 @@ use %s ) " (buffer-name) libname))))) + +;; «ruby-mode» (to ".ruby-mode") (defun ee-insert-test-ruby-mode () (interactive) (insert (ee-adjust-red-stars (format " @@ -377,6 +466,8 @@ load \"%s\" =end " (buffer-name))))) + +;; «scheme-mode» (to ".scheme-mode") ;; For Chez Scheme. (defun ee-insert-test-scheme-mode () (interactive) @@ -403,6 +494,8 @@ load \"%s\" ;; |# ;; " (buffer-name))))) + +;; «sml-mode» (to ".sml-mode") (defun ee-insert-test-sml-mode () (interactive) (insert (ee-adjust-red-stars (format " @@ -416,6 +509,8 @@ use \"%s\"; *) " (buffer-name))))) + +;; «sh-mode» (to ".sh-mode") (defun ee-insert-test-sh-mode () (interactive) (insert (ee-adjust-red-stars (format " @@ -428,6 +523,8 @@ use \"%s\"; %%%%%%%%%% " (buffer-name))))) + +;; «sql-mode» (to ".sql-mode") (defun ee-insert-test-sql-mode () (interactive) (insert (ee-adjust-red-stars (format " @@ -440,6 +537,8 @@ use \"%s\"; */ " (buffer-name))))) + +;; «subed-vtt-mode» (to ".subed-vtt-mode") (defun ee-insert-test-subed-vtt-mode () (interactive) (insert (ee-adjust-red-stars (ee-expand " @@ -489,6 +588,8 @@ NOTE subed-mpv-socket-dir ")))) + +;; «tcl-mode» (to ".tcl-mode") (defun ee-insert-test-tcl-mode () (interactive) (insert (ee-adjust-red-stars (format " @@ -501,6 +602,8 @@ lindex {{} {This is a test block: }} 0 ;# End of the test block " (buffer-name))))) + +;; «tuareg-mode» (to ".tuareg-mode") (defun ee-insert-test-tuareg-mode () (interactive) (insert (ee-adjust-red-stars (format " diff --git a/eev.el b/eev.el index 696a71af17..9d76d1b912 100644 --- a/eev.el +++ b/eev.el @@ -6,7 +6,7 @@ ;; Package-Requires: ((emacs "25.1")) ;; Keywords: lisp e-scripts ;; URL: http://anggtwu.net/#eev -;; Version: 20250607 +;; Version: 20250914 ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by