10sr 6 лет назад
Родитель
Сommit
54a198ba3d
Подписано: 10sr Идентификатор GPG ключа: 7BEC428194130EB2
1 измененных файлов: 32 добавлений и 7 удалений
  1. +32
    -7
      emacs.el

+ 32
- 7
emacs.el Просмотреть файл

@@ -1718,7 +1718,7 @@ This mode is a simplified version of `adoc-mode'."

(defcustom awk-preview-default-program
"{
print $0
print NR, $0
}
"
"Default awk command."
@@ -1740,6 +1740,11 @@ This mode is a simplified version of `adoc-mode'."
Used by preview buffer and always same as awk-preview--point-beg.")
(make-variable-buffer-local 'awk-preview--preview-point-beg)

(defvar awk-preview--program-filename
nil
"Awk preview program file name.")
(make-variable-buffer-local 'awk-preview--program-filename)

(defvar awk-preview--source-buffer
nil
"Awk source buffer.")
@@ -1794,9 +1799,20 @@ Return that buffer."
(setq awk-preview--source-buffer source)
(setq awk-preview--preview-buffer preview)
(setq awk-preview--program-buffer (current-buffer))
(unless buffer-file-name
(setq awk-preview--program-filename (make-temp-file "awk-preview-"
nil
".awk")))

(current-buffer))))

(defun awk-preview-program-buffer-kill-hook ()
"Cleanup for awk-preview program buffer."
(when awk-preview--program-filename
(delete-file awk-preview--program-filename)))
(add-hook 'kill-buffer-hook
'awk-preview-program-buffer-kill-hook)

(defun awk-preview--create-preview-buffer (source)
"Create preview buffer of SOURCE buffer and return it."
(with-current-buffer source
@@ -1840,15 +1856,24 @@ Return that buffer."

(switch-to-buffer awk-preview--program-buffer)

)

(defun awk-preview-update ()
"Update awk preview."
(interactive)
(let ((output (with-current-buffer (get-buffer-create " *awk-preview output*")
(erase-buffer)
(current-buffer))))
(awk-preview--invoke-awk awk-preview--source-buffer beg end output)
(with-current-buffer awk-preview--preview-buffer
(delete-region awk-preview--preview-point-beg (point))
(insert (with-current-buffer output
(buffer-substring-no-properties (point-min) (point-max)))))
))
(with-current-buffer awk-preview--source-buffer
(awk-preview--invoke-awk (current-buffer)
awk-preview--point-beg
awk-preview--point-end
output)
(with-current-buffer awk-preview--preview-buffer
(delete-region awk-preview--preview-point-beg (point))
(insert (with-current-buffer output
(buffer-substring-no-properties (point-min) (point-max)))))
)))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


Загрузка…
Отмена
Сохранить