Переглянути джерело

Add WIP awk-preview

master
10sr 6 роки тому
джерело
коміт
42e3b70fb5
Підписано: 10sr Ідентифікатор GPG ключа: 7BEC428194130EB2
1 змінених файлів з 49 додано та 0 видалено
  1. +49
    -0
      emacs.el

+ 49
- 0
emacs.el Переглянути файл

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

Завантаження…
Відмінити
Зберегти