(require 'evil) (require 'scribble) (require 'comint) (defun insert-lozenge () "inserts the lozenge character for use with Pollen" ;; enables function through M-x (interactive) ;; insert the proper character (insert (make-char 'mule-unicode-2500-33ff 34 42))) (defcustom scribble-target-format "pdf" "Options to build scribble document" :type 'string :group 'scribble-mode) (defun scribble-build () "Build scribble document" (interactive) (setq scribble-build-options (if (string= scribble-target-format "pdf") "--pdf" "--html")) (let* ((tmp-buf (current-buffer)) (file-name (buffer-file-name)) (cmd (concat "scribble " scribble-build-options " " file-name)) (buf-name "*scribble compilation *")) (if (fboundp 'compilation-start) (compilation-start cmd nil #'(lambda (mode-name) buf-name)) (compile-internal cmd "no more errors" buf-name)))) (defun scribble-set-target-format () (interactive) (let ((fmt (read-string "Output format:"))) (if (or (string= fmt "pdf") (string= fmt "html")) (setq scribble-target-format fmt) (message "Unsupported format %s\n" fmt)))) (defun scribble-view () (interactive) (let* ((file-name (concat (file-name-base (buffer-file-name)) "." scribble-target-format)) (cmd "open") (tmp-buf (current-buffer))) (apply 'make-comint cmd cmd nil (list file-name)) (switch-to-buffer tmp-buf) (switch-to-buffer-other-window (concat "*" cmd "*")))) (define-minor-mode evil-scribble-mode "Buffer local minor mode for evil-scribble " :init-value nil :lighter "EvilScribble" :keymap (make-sparse-keymap) :group 'evil-scribble) (mapc #'(lambda (state) (evil-define-key state evil-scribble-mode-map (kbd "M-b") 'scribble-build (kbd "M-f") 'scribble-set-target-format (kbd "M-v") 'scribble-view)) '(normal insert)) (global-set-key "\M-\\" 'insert-lozenge) (provide 'evil-scribble)