netguy204 / imp.el

Impatient html mode. See your changes in the browser as you type
http://www.youtube.com/watch?v=QV6XVyXjBO8
137 stars 28 forks source link

example of major-mode senstivity, i.e. org-mode support #19

Open bhyde opened 10 years ago

bhyde commented 10 years ago

Don't know if this is useful, but it made me happy.

(defun imp-htmlize-filter (buffer)
  "Alternate htmlization of BUFFER before sending to clients."
  (let ((m (with-current-buffer buffer major-mode)))
    (case m
      (org-mode
       (let ((output (current-buffer)))
         (with-current-buffer buffer
           (org-export-as-html 100 nil output))))
      (t
       (let ((html-buffer (save-match-data (htmlize-buffer buffer))))
         (insert-buffer-substring html-buffer)
         (kill-buffer html-buffer))))))

Other approaches would probably be better though.

Fun hack, thanks!

csarn commented 10 years ago

I modified the mode definition so that it also updates clients when visibility in org-mode is cycled:

;;;###autoload
(define-minor-mode impatient-mode
  "Serves the buffer live over HTTP."
  :group 'impatient-mode
  :lighter " imp"
  :keymap impatient-mode-map
  (if (not impatient-mode)
      (progn
        (remove-hook 'after-change-functions 'imp--on-change t)
        (when (eq major-mode 'org-mode)
          (remove-hook 'org-cycle-hook 'imp--on-change t)))

    (add-hook 'after-change-functions 'imp--on-change nil t)
    (when (eq major-mode 'org-mode)
      (add-hook 'org-cycle-hook 'imp--on-change t t))
    (imp-remove-user-filter)))
mashdot commented 9 years ago

Sorry for dragging up an old issue, but not sure how to get this to work?

I added @bhyde's code to my startup, and enabled impatient-mode on a .org file but all I get displayed is "Loading Content" which from what I can ascertain is /imp/static/loading.html

@bhyde are you still using this setup with org-mode?

mashdot commented 9 years ago

OK seems org-export-as-html needs to be changed to org-html-export-as-html. Unfortunately now getting a Process 'org-export-process' exited abnormally error in *Messages* and no output.

dustinlacewell commented 8 years ago

Hello, this is still basically the case. I would love to use this.