summaryrefslogtreecommitdiff
path: root/.emacs.d/lisp/yaml-mode.el
diff options
context:
space:
mode:
Diffstat (limited to '.emacs.d/lisp/yaml-mode.el')
-rw-r--r--.emacs.d/lisp/yaml-mode.el36
1 files changed, 18 insertions, 18 deletions
diff --git a/.emacs.d/lisp/yaml-mode.el b/.emacs.d/lisp/yaml-mode.el
index 1bfa43b..dad0380 100644
--- a/.emacs.d/lisp/yaml-mode.el
+++ b/.emacs.d/lisp/yaml-mode.el
@@ -78,7 +78,7 @@
78(defcustom yaml-indent-offset 2 78(defcustom yaml-indent-offset 2
79 "*Amount of offset per level of indentation." 79 "*Amount of offset per level of indentation."
80 :type 'integer 80 :type 'integer
81 :safe 'natnump 81 :safe #'natnump
82 :group 'yaml) 82 :group 'yaml)
83 83
84(defcustom yaml-backspace-function 'backward-delete-char-untabify 84(defcustom yaml-backspace-function 'backward-delete-char-untabify
@@ -186,11 +186,11 @@ that key is pressed to begin a block literal."
186 186
187(defvar yaml-mode-map 187(defvar yaml-mode-map
188 (let ((map (make-sparse-keymap))) 188 (let ((map (make-sparse-keymap)))
189 (define-key map "|" 'yaml-electric-bar-and-angle) 189 (define-key map "|" #'yaml-electric-bar-and-angle)
190 (define-key map ">" 'yaml-electric-bar-and-angle) 190 (define-key map ">" #'yaml-electric-bar-and-angle)
191 (define-key map "-" 'yaml-electric-dash-and-dot) 191 (define-key map "-" #'yaml-electric-dash-and-dot)
192 (define-key map "." 'yaml-electric-dash-and-dot) 192 (define-key map "." #'yaml-electric-dash-and-dot)
193 (define-key map (kbd "DEL") 'yaml-electric-backspace) 193 (define-key map (kbd "DEL") #'yaml-electric-backspace)
194 map) 194 map)
195 "Keymap used in `yaml-mode' buffers.") 195 "Keymap used in `yaml-mode' buffers.")
196 196
@@ -216,20 +216,18 @@ that key is pressed to begin a block literal."
216 216
217;;;###autoload 217;;;###autoload
218(define-derived-mode yaml-mode text-mode "YAML" 218(define-derived-mode yaml-mode text-mode "YAML"
219 "Simple mode to edit YAML. 219 "Simple mode to edit YAML."
220 220 (setq-local electric-indent-inhibit t) ;We can't *re*indent reliably.
221\\{yaml-mode-map}"
222 :syntax-table yaml-mode-syntax-table
223 (set (make-local-variable 'comment-start) "# ") 221 (set (make-local-variable 'comment-start) "# ")
224 (set (make-local-variable 'comment-start-skip) "#+ *") 222 (set (make-local-variable 'comment-start-skip) "#+ *")
225 (set (make-local-variable 'comment-end) "") 223 (set (make-local-variable 'comment-end) "")
226 (set (make-local-variable 'indent-line-function) 'yaml-indent-line) 224 (set (make-local-variable 'indent-line-function) #'yaml-indent-line)
227 (set (make-local-variable 'indent-tabs-mode) nil) 225 (set (make-local-variable 'indent-tabs-mode) nil)
228 (set (make-local-variable 'fill-paragraph-function) 'yaml-fill-paragraph) 226 (set (make-local-variable 'fill-paragraph-function) #'yaml-fill-paragraph)
229 (set (make-local-variable 'page-delimiter) "^---\\([ \t].*\\)*\n") 227 (set (make-local-variable 'page-delimiter) "^---\\([ \t].*\\)*\n")
230 228
231 (set (make-local-variable 'syntax-propertize-function) 229 (set (make-local-variable 'syntax-propertize-function)
232 'yaml-mode-syntax-propertize-function) 230 #'yaml-mode-syntax-propertize-function)
233 (setq font-lock-defaults '(yaml-font-lock-keywords))) 231 (setq font-lock-defaults '(yaml-font-lock-keywords)))
234 232
235 233
@@ -459,6 +457,7 @@ Outside of comments, this behaves as `fill-paragraph' except that
459filling does not cross boundaries of block literals. Inside comments, 457filling does not cross boundaries of block literals. Inside comments,
460this will do usual adaptive fill behaviors." 458this will do usual adaptive fill behaviors."
461 (interactive "*P") 459 (interactive "*P")
460 ;; FIXME: Can we get away with setting only `fill-forward-paragraph-function'?
462 (save-restriction 461 (save-restriction
463 (yaml-narrow-to-block-literal) 462 (yaml-narrow-to-block-literal)
464 (let ((fill-paragraph-function nil)) 463 (let ((fill-paragraph-function nil))
@@ -466,12 +465,13 @@ this will do usual adaptive fill behaviors."
466 (fill-paragraph justify region))))) 465 (fill-paragraph justify region)))))
467 466
468(defun yaml-set-imenu-generic-expression () 467(defun yaml-set-imenu-generic-expression ()
469 (make-local-variable 'imenu-generic-expression) 468 ;; FIXME: Why set this var to its default value?
470 (make-local-variable 'imenu-create-index-function) 469 (setq-local imenu-create-index-function #'imenu-default-create-index-function)
471 (setq imenu-create-index-function 'imenu-default-create-index-function) 470 (setq-local imenu-generic-expression yaml-imenu-generic-expression))
472 (setq imenu-generic-expression yaml-imenu-generic-expression))
473 471
474(add-hook 'yaml-mode-hook 'yaml-set-imenu-generic-expression) 472;; FIXME: Why not inline `yaml-set-imenu-generic-expression' into the
473;; major mode function?
474(add-hook 'yaml-mode-hook #'yaml-set-imenu-generic-expression)
475 475
476 476
477(defun yaml-mode-version () 477(defun yaml-mode-version ()