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
|
:init
|
||||||
;; Auto-detect C++ header files
|
;; Auto-detect C++ header files
|
||||||
(push (cons (lambda ()
|
(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
|
(or (file-exists-p (expand-file-name
|
||||||
(concat (file-name-sans-extension buffer-file-name)
|
(concat (file-name-sans-extension buffer-file-name)
|
||||||
".cpp")))
|
".cpp")))
|
||||||
|
@ -18,7 +19,9 @@
|
||||||
magic-mode-alist)
|
magic-mode-alist)
|
||||||
|
|
||||||
;; Auto-detect Obj-C header files
|
;; Auto-detect Obj-C header files
|
||||||
(push (cons (lambda () (and (equal (file-name-extension buffer-file-name) "h")
|
(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)))
|
(re-search-forward "@\\<interface\\>" magic-mode-regexp-match-limit t)))
|
||||||
'objc-mode)
|
'objc-mode)
|
||||||
magic-mode-alist)
|
magic-mode-alist)
|
||||||
|
|
|
@ -107,7 +107,8 @@
|
||||||
:init
|
:init
|
||||||
;; auto-detect JSX file
|
;; auto-detect JSX file
|
||||||
(push (cons (lambda ()
|
(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\\)"
|
(re-search-forward "\\(^\\s-*import React\\|\\( from \\|require(\\)[\"']react\\)"
|
||||||
magic-mode-regexp-match-limit t)
|
magic-mode-regexp-match-limit t)
|
||||||
(progn
|
(progn
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue