Hi,
I have a line
(setq auto-mode-alist (append auto-mode-alist
(list '("\\.F\\'" f90-mode "non-`nil'"))))
in my .emacs. It used to work OK with older emacs'es but I upgraded recently
and files with .F extension default to fortran f77 mode rather than to f90.
How to correct that?
Thanks,
Mark
|
|
0
|
|
|
|
Reply
|
mm5fan
|
7/14/2004 6:36:07 PM |
|
mp wrote:
> (setq auto-mode-alist (append auto-mode-alist
> (list '("\\.F\\'" f90-mode "non-`nil'"))))
That adds the entry to the *end* of auto-mode-alist, so it gets
over-ridden by the earlier (default) entry for .F, namely fortran
mode. Put your changes at the beginning. Also, I don't see why you
would want to use the third element (ie the "non-`nil'" bit) here. So
use:
(setq auto-mode-alist (append '(("\\.F\\'" . f90-mode)) auto-mode-alist))
Personally, I prefer add-to-list:
(add-to-list 'auto-mode-alist '("\\.F\\'" . f90-mode))
|
|
0
|
|
|
|
Reply
|
Glenn
|
7/15/2004 11:12:50 AM
|
|
Glenn Morris wrote:
| mp wrote:
|
| > (setq auto-mode-alist (append auto-mode-alist
| > (list '("\\.F\\'" f90-mode "non-`nil'"))))
|
| That adds the entry to the *end* of auto-mode-alist, so it gets
| over-ridden by the earlier (default) entry for .F, namely fortran
| mode. Put your changes at the beginning. Also, I don't see why you
| would want to use the third element (ie the "non-`nil'" bit) here. So
| use:
|
| (setq auto-mode-alist (append '(("\\.F\\'" . f90-mode)) auto-mode-alist))
|
| Personally, I prefer add-to-list:
|
| (add-to-list 'auto-mode-alist '("\\.F\\'" . f90-mode))
How would you do that with multiple mode specifications? My knowledge
of lists is disappointingly poor.
I have:
(add-to-list 'auto-mode-alist
'(("\\.c$" . c-mode)
("\\.html$" . html-mode)))
However, as add-to-list accepts one element only, this is not a
solution. I'd like to avoid having one call to add-to-list for each
file type, as there are quite a few. I'd also like to avoid append.
--
SB
I am so smart, so smart - s-m-r-t! I mean, s-m-A-r-t!
- Homer Simpson
|
|
0
|
|
|
|
Reply
|
s1726
|
7/17/2004 5:12:09 PM
|
|
Glenn Morris wrote:
| mp wrote:
|
| > (setq auto-mode-alist (append auto-mode-alist
| > (list '("\\.F\\'" f90-mode "non-`nil'"))))
|
| That adds the entry to the *end* of auto-mode-alist, so it gets
| over-ridden by the earlier (default) entry for .F, namely fortran
| mode. Put your changes at the beginning. Also, I don't see why you
| would want to use the third element (ie the "non-`nil'" bit) here. So
| use:
|
| (setq auto-mode-alist (append '(("\\.F\\'" . f90-mode)) auto-mode-alist))
|
| Personally, I prefer add-to-list:
|
| (add-to-list 'auto-mode-alist '("\\.F\\'" . f90-mode))
How would you do that with multiple mode specifications? My knowledge
of lists is disappointingly poor.
I have (example code shortened):
(add-to-list 'auto-mode-alist
'(("\\.c$" . c-mode)
("\\.html$" . html-mode)))
However, as add-to-list accepts one element only, this is not a
solution. I'd like to avoid having one call to add-to-list for each
file type, as there are quite a few. I'd also like to avoid append
for the reasons you mention.
--
SB
I am so smart, so smart - s-m-r-t! I mean, s-m-A-r-t!
- Homer Simpson
|
|
0
|
|
|
|
Reply
|
s1726
|
7/17/2004 5:13:08 PM
|
|
s1726@ii.uib.no (Steinar B.ANxrmer) writes:
> (add-to-list 'auto-mode-alist
> '(("\\.c$" . c-mode)
> ("\\.html$" . html-mode)))
>
> However, as add-to-list accepts one element only, this is not a
> solution. I'd like to avoid having one call to add-to-list for each
> file type, as there are quite a few. I'd also like to avoid append
> for the reasons you mention.
Just use append, but put your list as the first arg (rather than the
second arg as in your original example). `append' will append its
arguments in the order they are given.
-Miles
--
Somebody has to do something, and it's just incredibly pathetic that it
has to be us. -- Jerry Garcia
|
|
0
|
|
|
|
Reply
|
Miles
|
7/17/2004 9:36:45 PM
|
|
Miles Bader wrote:
| s1726@ii.uib.no (Steinar B�rmer) writes:
|
| > I'd also like to avoid append
|
| Just use append
Thank you. I'm looking for a way to make this work _without_ append,
as I've already stated. The reason I ask is partly to see if it's
at all possible to do this without append.
--
SB
I am so smart, so smart - s-m-r-t! I mean, s-m-A-r-t!
- Homer Simpson
|
|
0
|
|
|
|
Reply
|
s1726
|
7/18/2004 10:13:55 AM
|
|
s1726@ii.uib.no (Steinar B.ANxrmer) writes:
> | > I'd also like to avoid append
> |
> | Just use append
>
> Thank you. I'm looking for a way to make this work _without_ append,
> as I've already stated. The reason I ask is partly to see if it's
> at all possible to do this without append.
May I ask why? Of course you _can_ do it without append, but frankly,
given your constraints, append is the perfect solution -- the only
problem with your original attempt was that you put the arguments in the
wrong order.
You could also just use add-to-list in a loop, of course:
(dolist (entry '(("\.for$" . fortran-mode) ...))
(add-to-list 'auto-mode-alist entry))
-Miles
--
Fast, small, soon; pick any 2.
|
|
0
|
|
|
|
Reply
|
Miles
|
7/18/2004 12:36:44 PM
|
|
Miles Bader wrote:
| s1726@ii.uib.no (Steinar B�rmer) writes:
|
| > Thank you. I'm looking for a way to make this work _without_
| > append, as I've already stated. The reason I ask is partly to see
| > if it's at all possible to do this without append.
|
| May I ask why? Of course you _can_ do it without append, but
| frankly, given your constraints, append is the perfect solution --
| the only problem with your original attempt was that you put the
| arguments in the wrong order.
As noted in the post I replied to,
Message-ID: <fb1xjd34nh.fsf@xpc14.ast.cam.ac.uk>
appended items can sometimes be too far into the list, and therefore
could be ignored.
I'm trying to learn something about how lists work, too. I truly
don't know if you can "prepend" a list to a list, and how. I'd like
to see it, mostly for the reason stated above, but also for freedom of
choice. If you can do this, why would that not be "the perfect
solution" for me? What are the "constraints" that make it
less-than-ideal?
| You could also just use add-to-list in a loop, of course:
|
| (dolist (entry '(("\.for$" . fortran-mode) ...))
| (add-to-list 'auto-mode-alist entry))
Looks good, but is looping a good idea in ~/.emacs? Again, I'm trying
to learn the why, not only yes/no. =)
--
SB
I am so smart, so smart - s-m-r-t! I mean, s-m-A-r-t!
- Homer Simpson
|
|
0
|
|
|
|
Reply
|
s1726
|
7/18/2004 1:11:08 PM
|
|
s1726@ii.uib.no (Steinar B�rmer) writes:
> I'm trying to learn something about how lists work, too. I truly
> don't know if you can "prepend" a list to a list, and how.
Given two lists L1 and L2, what is the difference between appending
L2 to L1 and prepending L1 to L2?
They are the same, therefore the append function is enough:
(append L1 L2) appends L2 to L1, and also prepends L1 to L2.
Kai
|
|
0
|
|
|
|
Reply
|
Kai
|
7/18/2004 7:40:17 PM
|
|
Kai Grossjohann wrote:
| s1726@ii.uib.no (Steinar B�rmer) writes:
|
| > I'm trying to learn something about how lists work, too. I truly
| > don't know if you can "prepend" a list to a list, and how.
|
| Given two lists L1 and L2, what is the difference between appending
| L2 to L1 and prepending L1 to L2?
|
| They are the same, therefore the append function is enough:
| (append L1 L2) appends L2 to L1, and also prepends L1 to L2.
I seem to be more like my .sig at the moment. Vacation desperately
needed. Serious thanks.
*sigh*
--
SB
I am so smart, so smart - s-m-r-t! I mean, s-m-A-r-t!
- Homer Simpson
|
|
0
|
|
|
|
Reply
|
s1726
|
7/18/2004 8:06:15 PM
|
|
Miles Bader wrote:
| s1726@ii.uib.no (Steinar B�rmer) writes:
| > (add-to-list 'auto-mode-alist
| > '(("\\.c$" . c-mode)
| > ("\\.html$" . html-mode)))
|
| Just use append, but put your list as the first arg (rather than the
| second arg as in your original example). `append' will append its
| arguments in the order they are given.
It seems to me that there is a problem with this approach. My current
code is like this:
(add-to-list 'auto-mode-alist
(append '(("\\.c\\'" . c-mode)
("\\.pl\\'" . perl-mode)
("\\.html\\'" . html-mode))
))
Since it's a list that's being added to auto-mode-alist, the first and
last elements of my addded list get an extra parenthesis at the start
and end, respectively, like this:
C-h v auto-mode-alist RET
Value:
((("\\.c\\'" . c-mode)
("\\.pl\\'" . perl-mode)
("\\.html\\'" . html-mode))
("\\.py\\'" . python-mode)
("\\.mixal\\'" . mixal-mode)
[...]
When finding a file with one of those two extensions (in this case
c-mode or html-mode), Emacs complains:
File mode specification error: (wrong-type-argument stringp ("\\.c$" . c-mode))
and the corresponding mode is not loaded.
So it seems that adding a list to auto-mode-alist isn't a good idea at
all? Or is there something I'm missing in my code?
--
SB
I am so smart, so smart - s-m-r-t! I mean, s-m-A-r-t!
- Homer Simpson
|
|
0
|
|
|
|
Reply
|
s1726
|
7/19/2004 10:41:20 AM
|
|
s1726@ii.uib.no (Steinar B�rmer) writes:
> (add-to-list 'auto-mode-alist
> (append '(("\\.c\\'" . c-mode)
> ("\\.pl\\'" . perl-mode)
> ("\\.html\\'" . html-mode))
> ))
Originally, you had something like this:
(setq auto-mode-alist (append NEWVALUE auto-mode-alist))
Change this to:
(setq auto-mode-alist (append auto-mode-alist NEWVALUE))
Kai
|
|
0
|
|
|
|
Reply
|
Kai
|
7/19/2004 2:11:16 PM
|
|
Kai Grossjohann <kai@emptydomain.de> writes:
| s1726@ii.uib.no (Steinar B�rmer) writes:
|
| > (add-to-list 'auto-mode-alist
| > (append '(("\\.c\\'" . c-mode)
| > ("\\.pl\\'" . perl-mode)
| > ("\\.html\\'" . html-mode))
| > ))
|
| Originally, you had something like this:
|
| (setq auto-mode-alist (append NEWVALUE auto-mode-alist))
|
| Change this to:
|
| (setq auto-mode-alist (append auto-mode-alist NEWVALUE))
OK, thanks.
I guess I was unclear; I thought it was obvious by now that I'm trying
to learn how to work with lists in general, not just how to make
auto-mode-alist work. I guess it's not obvious. Using setq, I have a
working setup. I should have specified.
So, let me rephrase:
It seems to me that using add-to-list to add a whole list to
auto-mode-alist is a bad idea.
Any opinions on that?
--
SB
Horses are forbidden to eat fire hydrants in Marshalltown, Iowa, USA.
|
|
0
|
|
|
|
Reply
|
s1726
|
7/20/2004 7:52:44 AM
|
|
s1726@ii.uib.no (Steinar B�rmer) writes:
> It seems to me that using add-to-list to add a whole list to
> auto-mode-alist is a bad idea.
This depends. add-to-list will also check whether the to-be-added
element is already present. If so, add-to-list is a no-op.
I think for some number of elements, Lisp code like the following is
pretty clear:
(add-to-list 'auto-mode-alist '("\\.c\\'" . my-c-mode))
(add-to-list 'auto-mode-alist '("\\.c\\+\\+\\'" . my-c++-mode))
(add-to-list 'auto-mode-alist '("\\.java\\'" . my-java-mode))
The above code has a simple structure and is easy to maintain. Only
with lots of elements might this become too long to edit comfortably
and perhaps also too inefficient (due to the exhaustive list search
on every add-to-list statement).
When the list becomes long, then you might wish to do something
clever, but then you'll have to live with the consequences: to
maintain it, you need to be clever ;-)
Kai
|
|
0
|
|
|
|
Reply
|
Kai
|
7/21/2004 1:14:41 PM
|
|
Kai Grossjohann <kai@emptydomain.de> writes:
> I think for some number of elements, Lisp code like the following is
> pretty clear:
>
> (add-to-list 'auto-mode-alist '("\\.c\\'" . my-c-mode))
> (add-to-list 'auto-mode-alist '("\\.c\\+\\+\\'" . my-c++-mode))
> (add-to-list 'auto-mode-alist '("\\.java\\'" . my-java-mode))
An alternative can be:
(setq auto-mode-alist
(append
(list
'("\\.dcl$" . dtd-mode)
... ... ...
'("\\.c\\'" . my-c-mode)
'("\\.c\\+\\+\\'" . my-c++-mode)
'("\\.java\\'" . my-java-mode))
auto-mode-alist))
Best regards,
John
--
John Robot
|
|
0
|
|
|
|
Reply
|
John
|
7/22/2004 8:32:37 AM
|
|
s1726@ii.uib.no (Steinar B�rmer) writes:
> Glenn Morris wrote:
>
> | mp wrote:
> |
> | > (setq auto-mode-alist (append auto-mode-alist
> | > (list '("\\.F\\'" f90-mode "non-`nil'"))))
> |
> | That adds the entry to the *end* of auto-mode-alist, so it gets
> | over-ridden by the earlier (default) entry for .F, namely fortran
> | mode. Put your changes at the beginning. Also, I don't see why you
> | would want to use the third element (ie the "non-`nil'" bit) here. So
> | use:
> |
> | (setq auto-mode-alist (append '(("\\.F\\'" . f90-mode)) auto-mode-alist))
> |
> | Personally, I prefer add-to-list:
> |
> | (add-to-list 'auto-mode-alist '("\\.F\\'" . f90-mode))
>
> How would you do that with multiple mode specifications? My knowledge
> of lists is disappointingly poor.
>
> I have (example code shortened):
>
> (add-to-list 'auto-mode-alist
> '(("\\.c$" . c-mode)
> ("\\.html$" . html-mode)))
>
> However, as add-to-list accepts one element only, this is not a
> solution. I'd like to avoid having one call to add-to-list for each
> file type, as there are quite a few. I'd also like to avoid append
> for the reasons you mention.
I have some macrology for this purpose. Maybe I should have named it
"add-to-alist" instead of "set-assoc". It redefines an existing
association or adds a new new if none exists previously.
This defeats stack like handling of alist where you can push a new
association on front to shadow another association and then when you
pop it off, the old one becomes active again. Maybe I should just use
PUSH, make a delete first match for pop-alist, and then an operator
for removing shadowed associations if clean up is desired.
;;; .emacs configuration file
;; make assoc nicer
(defun get-assoc (alist key)
"get associate from searching alist with key"
(let ((match (assoc key alist)))
(if match
(cdr match)
nil)))
;; group function
(eval-and-compile
(defun group (source n)
"make nested list grouping source by n"
(when (zerop n) (error "zero length"))
(labels ((rec (source acc)
(let ((rest (nthcdr n source)))
(if (consp rest)
(rec rest (cons (subseq source 0 n) acc))
(nreverse (cons source acc))))))
(if source
(rec source nil)
nil))))
;; poor man's hash table
(defmacro set-one-assoc (alist key value)
(let ((match (gensym)))
`(let ((,match (assoc ,key ,alist)))
(if ,match
(progn
(rplacd ,match ,value)
,alist)
(setq ,alist (cons (cons ,key ,value) ,alist))))))
;; allow multiple associations at one time
(defmacro set-assoc (alist &rest implicit-pairs)
`(progn
,@(mapcar (lambda (pair)
`(set-one-assoc ,alist ,@pair))
(group implicit-pairs 2))))
;;;--- example
(set-assoc auto-mode-alist
"\\.c$" c-mode
"\\.html$" html-mode)
--
Johan KULLSTAM <kullstj-nn@comcast.net> sysengr
|
|
0
|
|
|
|
Reply
|
Johan
|
7/23/2004 2:38:02 PM
|
|
|
15 Replies
210 Views
(page loaded in 0.137 seconds)
Similiar Articles: define-generic-mode: how to control tab indentation? - comp.emacs ...indenting f90 do loops in vim - comp.lang.fortran f90 mode - comp.emacs define-generic-mode: how to control tab indentation? - comp.emacs ... indenting f90 do loops in vim ... Help needed: read 3-dimensional array from a MAT-file in Fortran ...> > Question: How to read the MAT-file in Fortran F90 and store the data in a similar 3 ... Open the mat file in read-only mode. !/ write(*,*) "... Opening mat file test ... size of a derived type containing pointers... - comp.lang.fortran ...C:\gfortran\clf\sizetest>type sizetest1.f90 program sizetest1 use ISO_C_BINDING ... > For example, using Oracle Solaris Fortran in 32-bit mode, the > program ... Something bad happened to my gfortran installation - comp.lang ...My best guess is that: C:\gfortran\clf\mxcsr>type utils_linux.f90 module utils ... * * We modify the affine mode bit and precision bits in this to give: * * affine ... Allocatable versus automatic arrays - comp.lang.fortranHi all, I have a huge F90 code composed by several modules, with several module ... For large arrays, use whatever mode seems natural for the problem; the memory ... Windows API programming with gfortran or g95 - comp.lang.fortran ...Compiled with: > ! gfortran -Wall -mwindows HelloWin2.f90 -oHelloWin2 -lgdi32 ... hello world" and asked how it compared with the half-dozen lines of the text-mode ... comp.parallel.mpi - page 2... have two vectors y[0...14] and x[0...14] distributed on 3 processors in this fashion ... about implementing MPI in f90 5 74 (7/11/2003 6:02:32 PM) hello all I have a f90 ... f77 and dynamic arrays in common blocks - comp.lang.fortran ...You can put F90 pointers in COMMON, but they aren't compatible with C pointers, so ... f77 and dynamic arrays in common blocks - comp.lang.fortran ..... after a fashion, is ... Bind crashs sometimes. - comp.protocols.dns.bind... 50% of the time all I get is ... svc:/network/rpc/bind:default in maintenance mode ... As previously mentioned, Fortran CHARACTER sometimes work ... char_std.f90 > program ... code speed moving from fortran 77 compiler to f2003 compiler ...The step from f77 to f90 is zero if you just want to take existing standard f77 ... I just got into crisis mode myself as I have been working on making our MS Excel ... Problem with cputime - comp.soft-sys.matlab... 0_12-b04 with Sun Microsystems Inc. Java HotSpot(TM) 64-Bit Server VM mixed mode ... Dear newsgroup, I encountered some problems with vector-valued functions in F90/F95 ... Detecting floating-point error code from Windows Gfortran - comp ...This we can do in Windows: C:\gfortran\clf\mxcsr>type mxcsr.f90 module mxcsr ... found a version which > supports setting/getting the underflow and rounding mode ... GUI for Fortran programs - comp.lang.fortranCompile and run using: gfortran -c do_fortran.f90 g++ -o fortran_cb ... Cons: need of working directory, the Fortran executable have to run in "batch" mode ... header's included but still get 'implicit declaration' - comp.unix ...... ether.h> #include <linux/ip.h> #include <linux/tcp.h> #include "my.h" .... void mode ... I still can't get any of the command line commands I try to ... wintest.f90 module ... Commercial Fortran Compilers - comp.lang.fortranJust imagine how different things would have been in the 80's if f90+COCO had been ... Use Ring0 mode in Visual Studio .NET - comp.lang.asm.x86 ... Commercial Fortran ... Bridge Mode for F90 Modem to Linsys Router - AT&T Community SupportTrying to bridge my F90 610025-06 Westell Modem w/ Linksys Router? In modem configuartion for my F90 I do not have a selection for Bridged Mode. It only has either ... LispForum • View topic - color coding comment in f90-mode using ...Emacs Lisp ... "Hi guys, I am rather new to lisp, and I hope you will forgive me ignorance. I have ..." · "As I look at fortran.el, the F77 comment syntax is ... 7/22/2012 4:02:49 AM
|