lang/{javascript,cc}: fix empty buffer-file-name in magic-mode-alist
This commit is contained in:
parent
c1db7f56ec
commit
8e5683eaa2
2 changed files with 8 additions and 4 deletions
|
@ -6,7 +6,8 @@
|
|||
:init
|
||||
;; Auto-detect C++ header files
|
||||
(push (cons (lambda ()
|
||||
(and (equal (file-name-extension buffer-file-name) "h")
|
||||
(and buffer-file-name
|
||||
(equal (file-name-extension buffer-file-name) "h")
|
||||
(or (file-exists-p (expand-file-name
|
||||
(concat (file-name-sans-extension buffer-file-name)
|
||||
".cpp")))
|
||||
|
@ -18,8 +19,10 @@
|
|||
magic-mode-alist)
|
||||
|
||||
;; Auto-detect Obj-C header files
|
||||
(push (cons (lambda () (and (equal (file-name-extension buffer-file-name) "h")
|
||||
(re-search-forward "@\\<interface\\>" magic-mode-regexp-match-limit t)))
|
||||
(push (cons (lambda ()
|
||||
(and buffer-file-name
|
||||
(equal (file-name-extension buffer-file-name) "h")
|
||||
(re-search-forward "@\\<interface\\>" magic-mode-regexp-match-limit t)))
|
||||
'objc-mode)
|
||||
magic-mode-alist)
|
||||
|
||||
|
|
|
@ -107,7 +107,8 @@
|
|||
:init
|
||||
;; auto-detect JSX file
|
||||
(push (cons (lambda ()
|
||||
(and (equal (file-name-extension buffer-file-name) "js")
|
||||
(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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue