Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
emacs
emacs
Commits
81860e46
Commit
81860e46
authored
Jan 15, 1994
by
Richard M. Stallman
Browse files
(set-auto-mode): Handle (REGEXP FUNCTION t) elements.
parent
9ba43e12
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
15 deletions
+28
-15
lisp/files.el
lisp/files.el
+28
-15
No files found.
lisp/files.el
View file @
81860e46
...
@@ -830,8 +830,11 @@ run `normal-mode' explicitly."
...
@@ -830,8 +830,11 @@ run `normal-mode' explicitly."
(
"\\.ml\\'"
.
lisp-mode
)))
(
"\\.ml\\'"
.
lisp-mode
)))
"\
"\
Alist
of
filename
patterns
vs
corresponding
major
mode
functions.
Alist
of
filename
patterns
vs
corresponding
major
mode
functions.
Each
element
looks
like
(
REGEXP
.
FUNCTION
)
.
Each
element
looks
like
(
REGEXP
.
FUNCTION
)
or
(
REGEXP
FUNCTION
)
.
Visiting
a
file
whose
name
matches
REGEXP
causes
FUNCTION
to
be
called.
")
Visiting
a
file
whose
name
matches
REGEXP
causes
FUNCTION
to
be
called.
If
the
element
has
the
form
(
REGEXP
FUNCTION
)
,
then
after
calling
FUNCTION,
we
delete
the
suffix
that
matched
REGEXP
and
search
the
list
again
for
another
match.
")
(defconst inhibit-local-variables-regexps '("
\\.tar$
")
(defconst inhibit-local-variables-regexps '("
\\.tar$
")
"
List
of
regexps
; if one matches a file name, don't look for local vars.")
"
List
of
regexps
; if one matches a file name, don't look for local vars.")
...
@@ -843,7 +846,7 @@ Visiting a file whose name matches REGEXP causes FUNCTION to be called.")
...
@@ -843,7 +846,7 @@ Visiting a file whose name matches REGEXP causes FUNCTION to be called.")
(
defun
set-auto-mode
()
(
defun
set-auto-mode
()
"Select major mode appropriate for current buffer.
"Select major mode appropriate for current buffer.
This checks for a -*- mode tag in the buffer's text, or
This checks for a -*- mode tag in the buffer's text, or
compares the filename against the entries in auto-mode-alist. It does
compares the filename against the entries in
`
auto-mode-alist
'
. It does
not check for the \"mode:\" local variable in the Local Variables
not check for the \"mode:\" local variable in the Local Variables
section of the file; for that, use `hack-local-variables'.
section of the file; for that, use `hack-local-variables'.
...
@@ -901,18 +904,28 @@ If `enable-local-variables' is nil, this function does not check for a
...
@@ -901,18 +904,28 @@ If `enable-local-variables' is nil, this function does not check for a
(
setq
done
t
)))
(
setq
done
t
)))
;; If we didn't find a mode from a -*- line, try using the file name.
;; If we didn't find a mode from a -*- line, try using the file name.
(
if
(
and
(
not
done
)
buffer-file-name
)
(
if
(
and
(
not
done
)
buffer-file-name
)
(
let
((
alist
auto-mode-alist
)
(
let
((
name
buffer-file-name
)
(
name
buffer-file-name
)
(
case-fold-search
(
eq
system-type
'vax-vms
))
mode
)
(
keep-going
t
))
(
let
((
case-fold-search
(
eq
system-type
'vax-vms
)))
;; Remove backup-suffixes from file name.
;; Remove backup-suffixes from file name.
(
setq
name
(
file-name-sans-versions
name
))
(
setq
name
(
file-name-sans-versions
name
))
(
while
keep-going
;; Find first matching alist entry.
(
setq
keep-going
nil
)
(
while
(
and
(
not
mode
)
alist
)
(
let
((
alist
auto-mode-alist
)
(
if
(
string-match
(
car
(
car
alist
))
name
)
(
mode
nil
))
(
setq
mode
(
cdr
(
car
alist
))))
;; Find first matching alist entry.
(
setq
alist
(
cdr
alist
))))
(
while
(
and
(
not
mode
)
alist
)
(
if
mode
(
funcall
mode
)))))))
(
if
(
string-match
(
car
(
car
alist
))
name
)
(
if
(
and
(
consp
(
cdr
(
car
alist
)))
(
nth
2
(
car
alist
)))
(
progn
(
setq
mode
(
car
(
cdr
(
car
alist
)))
name
(
substring
name
0
(
match-beginning
0
))
keep-going
t
))
(
setq
mode
(
cdr
(
car
alist
))
keep-going
nil
)))
(
setq
alist
(
cdr
alist
)))
(
if
mode
(
funcall
mode
))))))))))
(
defun
hack-local-variables-prop-line
()
(
defun
hack-local-variables-prop-line
()
;; Set local variables specified in the -*- line.
;; Set local variables specified in the -*- line.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment