mirror of
https://github.com/vale981/emacs-ipython-notebook
synced 2025-03-05 17:11:41 -05:00
Make logging buffer read only
This commit is contained in:
parent
62b2ed5152
commit
c2697e1e33
1 changed files with 13 additions and 7 deletions
20
ein-log.el
20
ein-log.el
|
@ -60,6 +60,14 @@
|
|||
(defun ein:log-level-name-to-int (name)
|
||||
(cdr (assq name ein:log-level-def)))
|
||||
|
||||
(defmacro ein:log-with-buffer (buffer &rest body)
|
||||
(declare (indent 1))
|
||||
`(with-current-buffer ,buffer
|
||||
(setq buffer-read-only t)
|
||||
(save-excursion
|
||||
(let ((inhibit-read-only t))
|
||||
,@body))))
|
||||
|
||||
(defun ein:log-wrapper (level func)
|
||||
(setq level (ein:log-level-name-to-int level))
|
||||
(when (<= level ein:log-level)
|
||||
|
@ -70,14 +78,12 @@
|
|||
(> (length msg) ein:log-max-string))
|
||||
(setq msg (substring msg 0 ein:log-max-string)))
|
||||
(when ein:log-buffer
|
||||
(with-current-buffer ein:log-buffer
|
||||
(save-excursion
|
||||
(goto-char (point-max))
|
||||
(insert msg "\n"))))
|
||||
(with-current-buffer (get-buffer-create ein:log-all-buffer-name)
|
||||
(save-excursion
|
||||
(ein:log-with-buffer ein:log-buffer
|
||||
(goto-char (point-max))
|
||||
(insert msg (format " @%S" orig-buffer) "\n")))
|
||||
(insert msg "\n")))
|
||||
(ein:log-with-buffer (get-buffer-create ein:log-all-buffer-name)
|
||||
(goto-char (point-max))
|
||||
(insert msg (format " @%S" orig-buffer) "\n"))
|
||||
(when (<= level ein:log-message-level)
|
||||
(message "ein: %s" msg)))))
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue