Quellcode durchsuchen

Add WIP awk-preview

master
10sr vor 6 Jahren
Ursprung
Commit
42e3b70fb5
Signiert von: 10sr GPG-Schlüssel-ID: 7BEC428194130EB2
1 geänderte Dateien mit 49 neuen und 0 gelöschten Zeilen
  1. +49
    -0
      emacs.el

+ 49
- 0
emacs.el Datei anzeigen

@@ -1506,4 +1506,53 @@ This mode is a simplified version of `adoc-mode'."
(add-to-list 'auto-mode-alist
'("\\.adoc\\'" . adoc-simple-mode)))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; awk-preview

(defgroup awk-preview nil
"Awk previewer."
:tag "Awk Preview"
:prefix "awk-preview-"
:group 'tools)

(defcustom awk-preview-program
(or (executable-find "gawk")
(executable-find "awk")
"awk")
"Awk program to execute."
:type 'string
:group 'awk-preview)

(defcustom awk-preview-switches
'("--sandbox" "--" "{print}")
"String of awk options appended when running awk preview."
:type '(repeat string)
:group 'awk-preview)

(defun awk-preview--invoke (start end output)
"Execute awk process and get result."
(let ((proc (apply 'start-process
"awk-preview"
output
awk-preview-program
awk-preview-switches)))
(message "%S" proc)
(process-send-region proc start end)
(process-send-eof proc)
(accept-process-output proc)
)
output)

(defun awk-preview (start end)
"Run awk and preview result."
(interactive "r")
(let ((output (with-current-buffer (get-buffer-create "*awk-preview output*")
(erase-buffer)
(current-buffer))))
(awk-preview--invoke start end output)
(message "awk-preview: %s" (with-current-buffer output
(buffer-substring-no-properties (point-min) (point-max))))
))

;;; emacs.el ends here

Laden…
Abbrechen
Speichern