Running shell command could be done with (shell-command COMMAND)
. Then we need to make string for executing command. We'll concatenate it from sections with (concat ...)
. We have 5 sections of the command:
(concat "aglio -i " ;; 1
(buffer-file-name) ;; 2
" -o " ;; 3
(file-name-sans-extension (buffer-file-name)) ;; 4
".html") ;; 5
So, if the buffer file name is foo.md
, then result of this script will be
aglio -i foo.md -o foo.html
We could make it function, like next:
(defun aglio-current-file ()
"Execute aglio shell command on current file"
(interactive)
(shell-command
(concat "aglio -i " (buffer-file-name)
" -o " (file-name-sans-extension (buffer-file-name)) ".html")))
We could define key for markdown-mode-map
with next code
(eval-after-load 'markdown-mode
'(define-key markdown-mode-map (kbd "C-c C-c s")
'aglio-current-file))
I use C-c C-c s
instead of C-c C-c
cause this version of the markdown package from melpa
uses C-c C-c
as prefix for buffer-wide commands.
C-c C-c
make different things into different major modes, inorg-mode
it have very much location-specific commands. But you could bind this on any key you want. But intomarkdown-mode
theC-c C-c
is the prefix key, so you'd better don't rebind it.