Skip to content

Instantly share code, notes, and snippets.

@bsag
Created April 8, 2015 10:03
Show Gist options
  • Select an option

  • Save bsag/49028cb2d25c59348fc4 to your computer and use it in GitHub Desktop.

Select an option

Save bsag/49028cb2d25c59348fc4 to your computer and use it in GitHub Desktop.
Marked.app private layer for Spacemacs

This is a silly little private layer I put together for Spacemacs to allow me to open the current (Markdown) buffer in Marked 2.app when I hit the key combo SPC om. Since I am very new to both Emacs and Spacemacs, I am not at all confident that the functions are in the appropriate places, and I am sure it could be done more simply. Having said all that, it works!

To activate it put the two .el files above within a folder called 'marked' within your 'private' folder (or whatever folder you have pointed dotspacemacs-configuration-layer-path at). Then you just need to add marked to your dotspacemacs-configuration-layers list in your .spacemacs.

;;; extensions.el --- marked Layer extensions File for Spacemacs
;;
;; Copyright (c) 2012-2014 Sylvain Benner
;; Copyright (c) 2014-2015 Sylvain Benner & Contributors
;;
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3
(defvar marked-pre-extensions
'(
;; pre extension markeds go here
)
"List of all extensions to load before the packages.")
(defvar marked-post-extensions
'(
;; post extension markeds go here
marked
)
"List of all extensions to load after the packages.")
;; For each extension, define a function marked/init-<extension-marked>
;;
;; (defun marked/init-my-extension ()
;; "Initialize my extension"
;; )
;;
;; Often the body of an initialize function uses `use-package'
;; For more info on `use-package', see readme:
;; https://github.com/jwiegley/use-package
(defun marked/init-marked ()
"Initialize Marked"
(use-package marked
:commands (marked/markdown-preview-file)
:init
(progn
(evil-leader/set-key
"om" 'marked/markdown-preview-file
))))
;;; packages.el --- marked Layer packages File for Spacemacs
;;
;; Copyright (c) 2012-2014 Sylvain Benner
;; Copyright (c) 2014-2015 Sylvain Benner & Contributors
;;
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3
(defvar marked-packages
'(
;; package markeds go here
)
"List of all packages to install and/or initialize. Built-in packages
which require an initialization must be listed explicitly in the list.")
(defvar marked-excluded-packages '()
"List of packages to exclude.")
;; For each package, define a function marked/init-<package-marked>
;;
;; (defun marked/init-my-package ()
;; "Initialize my package"
;; )
;;
;; Often the body of an initialize function uses `use-package'
;; For more info on `use-package', see readme:
;; https://github.com/jwiegley/use-package
(defun marked/markdown-preview-file ()
"Open current buffer in Marked 2.app"
(interactive)
(shell-command
(format "open -a '/Applications/Marked 2.app' %s"
(shell-quote-argument (buffer-file-name))))
)
(provide 'marked)
;;; marked package ends here
@stevenschobert
Copy link
Copy Markdown

Thanks for sharing this! This is super handy!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment