Procházet zdrojové kódy

Add WIP awk-preview

master
10sr před 6 roky
rodič
revize
42e3b70fb5
Podepsáno: 10sr ID GPG klíče: 7BEC428194130EB2
1 změnil soubory, kde provedl 49 přidání a 0 odebrání
  1. +49
    -0
      emacs.el

+ 49
- 0
emacs.el Zobrazit soubor

@@ -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

Načítá se…
Zrušit
Uložit