Refactor magic-mode-alist entries for rjsx-mode, c++-mode & objc-mode
This commit is contained in:
parent
3fcbdae441
commit
58198acf18
2 changed files with 18 additions and 19 deletions
|
@ -103,17 +103,16 @@
|
|||
:mode "\\.jsx$"
|
||||
:mode "components/.+\\.js$"
|
||||
:init
|
||||
;; auto-detect JSX file
|
||||
(push (cons (lambda ()
|
||||
(and buffer-file-name
|
||||
(equal (file-name-extension buffer-file-name) "js")
|
||||
(re-search-forward "\\(^\\s-*import React\\|\\( from \\|require(\\)[\"']react\\)"
|
||||
magic-mode-regexp-match-limit t)
|
||||
(progn
|
||||
(goto-char (match-beginning 1))
|
||||
(not (sp-point-in-string-or-comment)))))
|
||||
'rjsx-mode)
|
||||
magic-mode-alist)
|
||||
(defun +javascript-jsx-file-p ()
|
||||
(and buffer-file-name
|
||||
(equal (file-name-extension buffer-file-name) "js")
|
||||
(re-search-forward "\\(^\\s-*import React\\|\\( from \\|require(\\)[\"']react\\)"
|
||||
magic-mode-regexp-match-limit t)
|
||||
(progn
|
||||
(goto-char (match-beginning 1))
|
||||
(not (sp-point-in-string-or-comment)))))
|
||||
|
||||
(push (cons #'+javascript-jsx-file-p 'rjsx-mode) magic-mode-alist)
|
||||
|
||||
:config
|
||||
(set! :electric 'rjsx-mode :chars '(?\} ?\) ?. ?>))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue