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