Tweak Script-Fu config a little

This commit is contained in:
Camden Dixie O'Brien 2025-01-08 13:30:37 +00:00
parent 20e426dc69
commit 33e63ccda2

View File

@ -1185,7 +1185,7 @@
(setq Man-notify-method 'pushy)
#+end_src
** Script-Fu Mode
** Script-Fu
GIMP has a scheme-based language -- Script-Fu -- built into it that
you can use to script things (based). Sadly, the built-in console
is rather lackluster as a coding environment. Happily, there /is/
@ -1195,12 +1195,12 @@
It's things like this that make me really glad I switched to Emacs
because this is ridiculously cool. By my definition of "cool"
anyway -- what can I say, I'm a massive nerd.
anyway (what can I say, I'm a massive nerd).
I should probably extract this and make a standalone package out of
it and stick it on Melpa at some point.
*** REPL Mode
*** REPL
The Script-Fu server request format is very simple:
| Bytes | Description |
@ -1255,7 +1255,7 @@
The response format is similarly simple:
| Bytes | Content |
| Bytes | Description |
|-------+-----------------------------------------|
| 0 | 'G' magic byte (47h) |
| 1 | Status code -- 0 on success, 1 on error |
@ -1312,8 +1312,8 @@
(interactive)
(let ((buffer (get-buffer-create "*Script-Fu REPL*")))
(when (not (comint-check-proc buffer))
(make-comint-in-buffer "Script-Fu REPL" buffer
script-fu-repl-server)
(make-comint-in-buffer "Script-Fu REPL"
buffer script-fu-repl-server)
(with-current-buffer buffer (script-fu-repl-mode)))
(pop-to-buffer buffer '((display-buffer-in-direction)
(direction . below)
@ -1321,7 +1321,7 @@
buffer))
#+end_src
*** Code Editing Mode
*** Code Editing
With the client stuff done, we can define the code editing mode:
#+begin_src emacs-lisp
@ -1329,7 +1329,9 @@
#+end_src
Now to define something to send an expression or region to the
REPL:
REPL. Since =script-fu-repl= returns the buffer we can use that
to transparently start a REPL or get the existing one if one's
already running.
#+begin_src emacs-lisp
(defun script-fu-mode-send-region-or-sexp ()
@ -1340,21 +1342,19 @@
(buffer-substring-no-properties start end))
(thing-at-point 'sexp t))))
(if (not code) (message "No code to send.")
(let* ((repl-buffer (script-fu-repl))
(repl-proc (get-buffer-process repl-buffer)))
(let* ((repl-proc (get-buffer-process (script-fu-repl))))
(script-fu-repl-send repl-proc code)))))
(define-key script-fu-mode-map (kbd "C-c C-c")
'script-fu-mode-send-region-or-sexp)
#+end_src
And finally a similar thing for the whole file:
And finally, a similar thing for the whole file:
#+begin_src emacs-lisp
(defun script-fu-mode-send-file ()
(interactive)
(let* ((repl-buffer (script-fu-repl))
(repl-proc (get-buffer-process repl-buffer))
(let* ((repl-proc (get-buffer-process (script-fu-repl)))
(buffer-contents
(buffer-substring-no-properties (point-min)
(point-max))))