mirror of https://github.com/Chizi123/.emacs.d.git

Chizi123
2018-11-17 c4001ccd1864293b64aa37d83a9d9457eb875e70
commit | author | age
5cb5f7 1 ;;; smartparens-org.el --- Configuration for Org mode.  -*- lexical-binding: t; -*-
C 2
3 ;; Copyright (C) 2017 Matúš Goljer
4
5 ;; Author: Matúš Goljer <matus.goljer@gmail.com>
6 ;; Maintainer: Matúš Goljer <matus.goljer@gmail.com>
7 ;; Version: 0.0.1
8 ;; Created: 15th January 2017
9 ;; Keywords: languages
10
11 ;; This program is free software; you can redistribute it and/or
12 ;; modify it under the terms of the GNU General Public License
13 ;; as published by the Free Software Foundation; either version 3
14 ;; of the License, or (at your option) any later version.
15
16 ;; This program is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 ;; GNU General Public License for more details.
20
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
23
24 ;;; Commentary:
25
26 ;; This file provides some additional configuration for Org based
27 ;; modes.  To use it, simply add:
28 ;;
29 ;; (require 'smartparens-org)
30 ;;
31 ;; into your configuration.  You can use this in conjunction with the
32 ;; default config or your own configuration.
33 ;;
34 ;; If you have good ideas about what should be added please file an
35 ;; issue on the github tracker.
36 ;;
37 ;; For more info, see github readme at
38 ;; https://github.com/Fuco1/smartparens
39
40 ;;; Code:
41
42 (require 'smartparens)
43 (require 'smartparens-text)
44
45 (defun sp--org-skip-asterisk (_ms mb me)
46   "Non-nil if the asterisk is part of the outline marker."
47   (save-excursion
48     (goto-char mb)
49     (beginning-of-line)
50     (let ((skip-distance (skip-chars-forward "*")))
51       (if (= skip-distance 1)
52           (not (memq (syntax-class (syntax-after (point))) '(2 3)))
53         (<= me (point))))))
54
55 (sp-with-modes 'org-mode
56   (sp-local-pair "*" "*"
57                  :unless '(sp-point-after-word-p sp-point-at-bol-p)
58                  :skip-match 'sp--org-skip-asterisk)
59   (sp-local-pair "_" "_" :unless '(sp-point-after-word-p))
60   (sp-local-pair "/" "/" :unless '(sp-point-after-word-p) :post-handlers '(("[d1]" "SPC")))
61   (sp-local-pair "~" "~" :unless '(sp-point-after-word-p) :post-handlers '(("[d1]" "SPC")))
62   (sp-local-pair "=" "=" :unless '(sp-point-after-word-p) :post-handlers '(("[d1]" "SPC")))
63   (sp-local-pair "«" "»"))
64
65 (provide 'smartparens-org)
66 ;;; smartparens-org.el ends here