Skip to content

Commit

Permalink
add new function org-pandoc-new
Browse files Browse the repository at this point in the history
  • Loading branch information
deactivated committed Feb 5, 2012
1 parent 011b10c commit 5cc677f
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 10 deletions.
7 changes: 7 additions & 0 deletions applescript/org-pandoc-new.applescript
@@ -0,0 +1,7 @@
tell application id "com.devon-technologies.thinkpro2"
set active_selection to selection
set selection_name to name of item 1 of active_selection
set selection_path to path of item 1 of active_selection
set appname to (path to frontmost application as Unicode text)
do shell script "emacsclient -n -e '(org-pandoc-new nil \"'" & quoted form of appname & "'\")'"
end tell
File renamed without changes.
42 changes: 32 additions & 10 deletions elisp/org-pandoc.el
Expand Up @@ -145,21 +145,20 @@ end tell'" app)))
(rename-buffer (format "*Pandoc: %s*" name) t) (rename-buffer (format "*Pandoc: %s*" name) t)
(setq org-pandoc-orig-file (aref record 1)) (setq org-pandoc-orig-file (aref record 1))
(org-pandoc-mode 1)) (org-pandoc-mode 1))
;(delete-file outfile) (delete-file outfile))))
(message "%s" outfile)
)))

(set-buffer-modified-p nil)) (set-buffer-modified-p nil))




(defun org-pandoc-commit () (defun org-pandoc-commit ()
(interactive) (interactive)
(when org-pandoc-orig-app (org-pandoc-save)
(org-pandoc-save) (let (buf (current-buffer))
(when org-pandoc-orig-app (if org-pandoc-orig-app
(focus-window org-pandoc-orig-app)) (progn
(kill-buffer) (focus-window org-pandoc-orig-app)
(delete-frame))) (kill-buffer buf)
(delete-frame))
(kill-buffer buf))))




(defun org-pandoc-open (infile &optional inname inapp) (defun org-pandoc-open (infile &optional inname inapp)
Expand All @@ -184,6 +183,29 @@ end tell'" app)))
(select-frame-set-input-focus (selected-frame)))))) (select-frame-set-input-focus (selected-frame))))))




(defun org-pandoc-new (&optional mode inapp)
(interactive)
(when (null mode)
(setq mode 'org-mode))

(let* ((buf-name (loop for n upfrom 0
for name = (format "*Pandoc: Untitled%s*"
(if (= n 0) "" (format " (%d)" n)))
while (get-buffer name)
finally return name))
(buf (get-buffer-create buf-name)))
(with-current-buffer buf
(funcall mode)
(org-pandoc-mode 1)
(set (make-local-variable 'org-pandoc-orig-app) inapp))
(if inapp
(with-selected-frame (make-frame)
(switch-to-buffer buf)
(select-frame-set-input-focus (selected-frame)))
(switch-to-buffer buf))
buf))


(define-minor-mode org-pandoc-mode (define-minor-mode org-pandoc-mode
"Toggle org-pandoc-mode. "Toggle org-pandoc-mode.
With no argument, this command toggles the mode. With no argument, this command toggles the mode.
Expand Down

0 comments on commit 5cc677f

Please sign in to comment.