2016-12-19 15:45:41 +00:00
|
|
|
;;; funcs.el --- Markdown Layer Functions File for Spacemacs
|
|
|
|
;;
|
2021-03-22 20:11:29 +00:00
|
|
|
;; Copyright (c) 2012-2021 Sylvain Benner & Contributors
|
2016-12-19 15:45:41 +00:00
|
|
|
;;
|
|
|
|
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
|
|
|
;; URL: https://github.com/syl20bnr/spacemacs
|
|
|
|
;;
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
;;
|
2021-03-24 03:31:44 +00:00
|
|
|
;; This program is free software; you can redistribute it and/or modify
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
;; (at your option) any later version.
|
|
|
|
;;
|
|
|
|
;; This program is distributed in the hope that it will be useful,
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
;;
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
|
|
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2016-12-19 15:45:41 +00:00
|
|
|
|
|
|
|
(defun spacemacs/activate-mmm-mode ()
|
2021-02-21 22:34:02 +00:00
|
|
|
(unless (bound-and-true-p git-commit-mode)
|
|
|
|
;; Enable `mmm-mode'.
|
2020-12-09 18:44:15 +00:00
|
|
|
(mmm-mode 1)))
|
2017-04-29 15:08:03 +00:00
|
|
|
|
|
|
|
;; stolen from http://stackoverflow.com/a/26297700
|
|
|
|
;; makes markdown tables saner via orgtbl-mode
|
|
|
|
(defun spacemacs//cleanup-org-tables ()
|
|
|
|
(require 'org-table)
|
|
|
|
(save-excursion
|
|
|
|
(goto-char (point-min))
|
|
|
|
(while (search-forward "-+-" nil t) (replace-match "-|-"))))
|
|
|
|
|
2017-05-18 16:20:05 +00:00
|
|
|
(defun spacemacs//cleanup-org-tables-on-save ()
|
|
|
|
(add-hook 'before-save-hook 'spacemacs//cleanup-org-tables nil 'local))
|
|
|
|
|
2017-04-29 15:08:03 +00:00
|
|
|
;; Insert key for org-mode and markdown a la C-h k
|
|
|
|
;; from SE endless http://emacs.stackexchange.com/questions/2206/i-want-to-have-the-kbd-tags-for-my-blog-written-in-org-mode/2208#2208
|
|
|
|
(defun spacemacs/insert-keybinding-markdown (key)
|
|
|
|
"Ask for a key then insert its description.
|
|
|
|
Will work on both org-mode and any mode that accepts plain html."
|
|
|
|
(interactive "kType key sequence: ")
|
|
|
|
(let* ((tag "~%s~"))
|
|
|
|
(if (null (equal key "\r"))
|
|
|
|
(insert
|
|
|
|
(format tag (help-key-description key nil)))
|
|
|
|
(insert (format tag ""))
|
|
|
|
(forward-char -6))))
|
2017-07-07 09:36:22 +00:00
|
|
|
|
|
|
|
;; from Jason Blevins http://jblevins.org/log/mmm
|
|
|
|
(defun markdown/mmm-auto-class (lang)
|
|
|
|
(let* ((l (if (listp lang) (car lang) lang))
|
|
|
|
(s (if (listp lang) (cadr lang) lang))
|
|
|
|
(class (intern (concat "markdown-" l)))
|
|
|
|
(submode (intern (concat s "-mode")))
|
|
|
|
(front (concat "^```" l "[\n\r]+"))
|
|
|
|
(back "^```$"))
|
|
|
|
(mmm-add-classes (list (list class
|
|
|
|
:submode submode
|
|
|
|
:front front
|
|
|
|
:back back)))
|
|
|
|
(dolist (mode markdown--key-bindings-modes)
|
|
|
|
(mmm-add-mode-ext-class mode nil class))))
|
2018-06-06 05:15:48 +00:00
|
|
|
|
|
|
|
(defun spacemacs//markdown-hjkl-promotion-demotion (style)
|
|
|
|
"Set promotion/demotiion on 'hjkl' for the given editing STYLE."
|
|
|
|
(when (or (eq 'vim style)
|
|
|
|
(and (eq 'hybrid style)
|
2018-06-08 06:20:47 +00:00
|
|
|
hybrid-style-enable-hjkl-bindings))
|
2018-06-06 05:15:48 +00:00
|
|
|
(dolist (s '(normal insert))
|
|
|
|
(evil-define-key s markdown-mode-map
|
|
|
|
(kbd "M-h") 'markdown-promote
|
|
|
|
(kbd "M-j") 'markdown-move-down
|
|
|
|
(kbd "M-k") 'markdown-move-up
|
|
|
|
(kbd "M-l") 'markdown-demote))))
|