unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* patch to recognize file variables in the case of haskell pragmas, etc.
@ 2012-04-29 22:25 Ransom Williams
  2012-04-30  0:43 ` Ransom Williams
  0 siblings, 1 reply; 3+ messages in thread
From: Ransom Williams @ 2012-04-29 22:25 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 422 bytes --]

tali713 in the #emacs channel on irc.freenode suggested i submit this
as a patch:

The regexps to pass over when looking for -*-file:variables-*-, namely
"^#!" and "^'\\\\\"", were previously hardcoded in the set-auto-mode-1
function.  They are now in the file-auto-mode-ignore list along with a
regular expression for haskell pragmas.

i am not on the list, but feel free to copy me on any comments that
need addressing.

[-- Attachment #2: PATCH.txt --]
[-- Type: text/plain, Size: 2635 bytes --]

# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: ransom@ugcs.caltech.edu-20120429215832-gz46s6sacd0i2qb6
# target_branch: file:///home/ransom/Code/bzr/emacs/trunk/
# testament_sha1: 3c93919614def2f05c63cb686c38a63386c49f4e
# timestamp: 2012-04-29 15:03:45 -0700
# base_revision_id: schwab@linux-m68k.org-20120429200544-\
#   rzfzg034jvr9f6le
# 
# Begin patch
=== modified file 'lisp/files.el'
--- lisp/files.el	2012-04-26 03:18:47 +0000
+++ lisp/files.el	2012-04-29 21:58:32 +0000
@@ -2781,6 +2781,9 @@
       (funcall mode)
       mode)))
 
+(setq file-auto-mode-ignore
+      (list "^#!" "^'\\\\\"" "^\{-#.*#-}$"))
+
 (defun set-auto-mode-1 ()
   "Find the -*- spec in the buffer.
 Call with point at the place to start searching from.
@@ -2803,7 +2806,7 @@
                             ;; interpreter invocation.  The same holds
                             ;; for '\" in man pages (preprocessor
                             ;; magic for the `man' program).
-                            (and (looking-at "^\\(#!\\|'\\\\\"\\)") 2)) t)
+                            (and (memq 't (mapcar 'looking-at file-auto-mode-ignore)) 2)) t)
      (progn
        (skip-chars-forward " \t")
        (setq beg (point))

# Begin bundle
IyBC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JHC3CUMui3dE0W2BwJma4sEge4sY4i810ctS7N1czZ1afEUrsOpMlT37FJ/HAz4VUI3VOMKmk
fLGElEHsquN8GOakBREJuTC39pqrWA7jUcAHVB3SNpMrrDA6J69YK23yry2sy/OUCdN85xruXuKF
KNtXgmeFnbL0O0Z3lItfWhueBFQs8HrhU+6MQ6lNP6kmXgKphZ3KDd1Tiy0GroejbgI0Zpor8KjG
bm+pFu1KuQ6WrtrOooFatYiyuvF3JjyS+O7vrvKLHonK4O9fVROauWpYzWpaeYroqCxUvmf/i7ki
nChIFqipO4A=

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: patch to recognize file variables in the case of haskell pragmas, etc.
  2012-04-29 22:25 patch to recognize file variables in the case of haskell pragmas, etc Ransom Williams
@ 2012-04-30  0:43 ` Ransom Williams
  2012-05-05  3:22   ` Stefan Monnier
  0 siblings, 1 reply; 3+ messages in thread
From: Ransom Williams @ 2012-04-30  0:43 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 569 bytes --]

uurk, typo/force of habit, sorry...

On Sun, Apr 29, 2012 at 3:25 PM, Ransom Williams <auvergnerw@gmail.com> wrote:
> tali713 in the #emacs channel on irc.freenode suggested i submit this
> as a patch:
>
> The regexps to pass over when looking for -*-file:variables-*-, namely
> "^#!" and "^'\\\\\"", were previously hardcoded in the set-auto-mode-1
> function.  They are now in the file-auto-mode-ignore list along with a
> regular expression for haskell pragmas.
>
> i am not on the list, but feel free to copy me on any comments that
> need addressing.

[-- Attachment #2: PATCH2.txt --]
[-- Type: text/plain, Size: 3059 bytes --]

# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: ransom@ugcs.caltech.edu-20120430003851-040ddqugj3fqgscg
# target_branch: file:///home/ransom/Code/bzr/emacs/trunk/
# testament_sha1: 096e8633989e1a79c5b7b68433b46fcae783b629
# timestamp: 2012-04-29 17:39:04 -0700
# base_revision_id: schwab@linux-m68k.org-20120429200544-\
#   rzfzg034jvr9f6le
# 
# Begin patch
=== modified file 'lisp/files.el'
--- lisp/files.el	2012-04-26 03:18:47 +0000
+++ lisp/files.el	2012-04-30 00:38:51 +0000
@@ -2781,6 +2781,9 @@
       (funcall mode)
       mode)))
 
+(setq file-auto-mode-ignore
+      (list "^#!" "^'\\\\\"" "^{-#.*#-}$"))
+
 (defun set-auto-mode-1 ()
   "Find the -*- spec in the buffer.
 Call with point at the place to start searching from.
@@ -2803,7 +2806,7 @@
                             ;; interpreter invocation.  The same holds
                             ;; for '\" in man pages (preprocessor
                             ;; magic for the `man' program).
-                            (and (looking-at "^\\(#!\\|'\\\\\"\\)") 2)) t)
+                            (and (memq 't (mapcar 'looking-at file-auto-mode-ignore)) 2)) t)
      (progn
        (skip-chars-forward " \t")
        (setq beg (point))

# Begin bundle
IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWSue92AAAxB/gDAQAEB88//3
UgAABb////pQBb7rax0AHXQJAGnCSmlPUmymnoaZTT0hkbJlPU8kaADQ0EpUPUYjT1MagNGg0aaA
BkNAAlNSaJhJtRjUeoNAxHo9RB6jZTEA5gAJgACYAAAAACSQJoGgRoBGQIekaoHpqYaT1OxEu3ae
ATgf7ie5xHHA71jmDm6E2rAN/OLc+hEfJM6IkfSMRNdC8rC++h8cZ6GcQJJF1o0jzAIYYNKODXJz
6vaP4LvxlllTgcfx+R+3ZaVsWsGjBK5qlUMTSvlIicgT5tXrHSU9ZWeAoosAniPMxXF5xInkhBQE
aeo7/NxKdlmo/iwbrDgX1NxAICGdORiKzIPP5eJwKxb1eVWne4s5ppoCCMQOFuWPmZ+mlM3OdEXM
GSzvHfQWIsUkoRs7zuVQqj0EwhVVNBbSZOHd5ZCMJC1eKKIUeKX25zKh4jpXLIU2RaLLqfs/iFni
ZCvEw8gYF+CEZOrbIrEsDQlAKgK48WxBbI2cbgllYpweKQVAtF09MUa7MZ2CI4reK4YEf8IAiIoi
Ja460rLYOCycxcBiKFjfpeUSu2llpfnmItl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HsEYjxGCwkDiRn5FgeBWlYK5iLCvJUAPQTL2EHcDxPW2hYsfq
JwqAeq+FE8hXizWRULMXDXkIXWCqj6NE0zh/F3JFOFCQK573YA==

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: patch to recognize file variables in the case of haskell pragmas, etc.
  2012-04-30  0:43 ` Ransom Williams
@ 2012-05-05  3:22   ` Stefan Monnier
  0 siblings, 0 replies; 3+ messages in thread
From: Stefan Monnier @ 2012-05-05  3:22 UTC (permalink / raw)
  To: Ransom Williams; +Cc: emacs-devel

>>>>> "Ransom" == Ransom Williams <auvergnerw@gmail.com> writes:

> uurk, typo/force of habit, sorry...

> On Sun, Apr 29, 2012 at 3:25 PM, Ransom Williams <auvergnerw@gmail.com> wrote:
>> tali713 in the #emacs channel on irc.freenode suggested i submit this
>> as a patch:
>> 
>> The regexps to pass over when looking for -*-file:variables-*-, namely
>> "^#!" and "^'\\\\\"", were previously hardcoded in the set-auto-mode-1
>> function.  They are now in the file-auto-mode-ignore list along with a
>> regular expression for haskell pragmas.
>> 
>> i am not on the list, but feel free to copy me on any comments that
>> need addressing.

Thank you for your contribution.  I installed the patch below instead:
it's not much more difficult to (concat foo "\\|bla") than it is to add
to a list.


        Stefan


=== modified file 'lisp/files.el'
--- lisp/files.el	2012-05-04 23:16:47 +0000
+++ lisp/files.el	2012-05-05 03:18:37 +0000
@@ -2782,6 +2782,11 @@
       (funcall mode)
       mode)))
 
+(defvar file-auto-mode-skip "^\\(#!\\|'\\\\\"\\)"
+  "Regexp of lines to skip when looking for file-local settings.
+If the first line matches this regular expression, then the -*-...-*- file-
+local settings will be consulted on the second line instead of the first."
+
 (defun set-auto-mode-1 ()
   "Find the -*- spec in the buffer.
 Call with point at the place to start searching from.
@@ -2804,7 +2809,7 @@
                             ;; interpreter invocation.  The same holds
                             ;; for '\" in man pages (preprocessor
                             ;; magic for the `man' program).
-                            (and (looking-at "^\\(#!\\|'\\\\\"\\)") 2)) t)
+                            (and (looking-at file-auto-mode-skip) 2)) t)
      (progn
        (skip-chars-forward " \t")
        (setq beg (point))




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-05-05  3:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-29 22:25 patch to recognize file variables in the case of haskell pragmas, etc Ransom Williams
2012-04-30  0:43 ` Ransom Williams
2012-05-05  3:22   ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).