-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmode-compile.el
2650 lines (2347 loc) · 99.1 KB
/
mode-compile.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;;; mode-compile.el --- Smart command for compiling files
;; according to major-mode.
;;
;; Copyright (c) 1994 - 2006 heddy Boubaker C.E.N.A.
;;
;; Author: Heddy Boubaker <[email protected]>
;; Maintainer: Heddy Boubaker <[email protected]>
;; Created: June 1994
;; Last modified: 2006/12/01 13:52:47
;; Version: 2.29
;; Keywords: compile, compilation, modes, languages
;; Tested for:
;; XEmacs (Lucid GNU Emacs) >= 19.10
;; Must work with FSF GNU Emacs > 19.31 ;-)
;; Do not work anymore for Emacses <= 18
;; Ftp access:
;; archive.cis.ohio-state.edu:pub/gnu/emacs/elisp-archive/misc/mode-compile.el.Z
;; WWW access:
;; <URL http://www.tls.cena.fr/~boubaker/Emacs/>
;;
;; LCD Archive Entry:
;; mode-compile|Heddy Boubaker|[email protected]|
;; Smart command for compiling files according to major-mode and more.|
;; 2003/04/01 13:52:47|2.28|~/misc/mode-compile.el.Z|
;;
;;; This file is NOT part of GNU Emacs but the same permissions apply.
;;
;; GNU Emacs is free software; you can redistribute it and/or modify it under
;; the terms of the GNU General Public License as published by the Free
;; Software Foundation; either version 2, or (at your option) any later
;; version.
;;
;; GNU Emacs is distributed in the hope that it will be useful, but WITHOUT
;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
;; more details.
;;
;; You should have received a copy of the GNU General Public License along
;; with GNU Emacs; see the file COPYING. If not, write to the Free Software
;; Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
;;
;; @ Purpose:
;; ==========
;;
;; Provide `mode-compile' function as a replacement for the use of `compile'
;; command which is very dumb for creating it's compilation command (use
;; "make -k" by default). `mode-compile' is a layer above `compile'; Its
;; purpose is mainly to build a smart compile-command for `compile' to
;; execute it. This compile-command is built according to number of
;; parameters:
;; - the major-mode.
;; - presence or not of a makefile in current directory.
;; - the buffer-file-name and extension.
;; - what is in the current buffer (`main' function,"#!/path/shell", ...).
;; - and more ... (see Commentary section below).
;; Most of these parameters are higly customizable throught Emacs Lisp
;; variables (to be set in your .emacs or through Customization menu).
;; Running mode-compile after an universal-argument (C-u) allows remote
;; compilations, user is prompted for a host name to run the compilation
;; command on. Another function provided is `mode-compile-kill' which
;; terminate a running compilation session launched by `mode-compile'.
;;
;; @ Installation:
;; ===============
;;
;; Byte compile this file (*) somewhere in your `load-path' and add in
;; your .emacs:
;; (autoload 'mode-compile "mode-compile"
;; "Command to compile current buffer file based on the major mode" t)
;; (global-set-key "\C-cc" 'mode-compile)
;; (autoload 'mode-compile-kill "mode-compile"
;; "Command to kill a compilation launched by `mode-compile'" t)
;; (global-set-key "\C-ck" 'mode-compile-kill)
;;
;; By default mode-compile is very verbose and waits a few seconds (1 by
;; default) after each message for the user to have time to read it. You
;; could set variables `mode-compile-expert-p' and
;; `mode-compile-reading-time' to change this behaviour. On X-Windows
;; systems setting the variable `mode-compile-other-frame-p' will create a
;; new frame and launch the compilation command in it.
;;
;; (*) Don't take care of messages:
;; ** reference to free variable efs-remote-shell-file-name
;; This is perfectly normal ;-}. But if you know a way to avoid it let me
;; know.
;;
;; @ Bug Reports:
;; ==============
;;
;; To report a bug please use function `mode-compile-submit-bug-report'
;; Please note that this bug-report facility uses Barry Warsaw's reporter.el
;; which is part of GNU Emacs v19 and bundled with many other packages. If
;; needed, you can obtain a copy of reporter.el at the elisp-archive.
;;
;; @ Documentation:
;; ================
;;
;; This section will explain how the `compile-command' are built according to
;; the `major-mode' and how to customize it. The major modes `mode-compile'
;; currently known are:
;; - c-mode, c++-mode, makefile-mode, dired-mode, ada-mode, emacs-lisp-mode,
;; lisp-interaction-mode, sh-mode, csh-mode, fundamental-mode, text-mode,
;; indented-text-mode compilation-mode, fortran-mode, c?perl-mode,
;; zsh-mode java-mode, tcl-mode, python-mode, ruby-mode
;; For other modes a default behaviour is provided.
;;
;; When running `mode-compile' or `mode-compile-kill' the hooks
;; `mode-compile-(before|after)-(compile|kill)-hook' are executed. The
;; current buffer could be automaticaly saved if variable
;; `mode-compile-always-save-buffer-p' is set to `t'. ALL the modified
;; buffers could be automaticaly saved if variable `mode-compile-save-all-p'
;; is set to `t'.
;;
;; @@ fundamental-mode, text-mode, indented-text-mode & UNKNOWN MODES:
;; *** THIS IS TOO THE DEFAULT BEHAVIOR FOR UNKNOWN MODES ***
;; Try to guess what the file is by:
;; - 1st looking at it's name and extension (see variable
;; `mode-compile-filename-regexp-alist').
;; - 2nd looking at string "#!/path/shell" at first line to extract shell
;; to run the script with (see variable `mode-compile-shell-alist').
;; - 3rd looking at a makefile in current directory.
;; - then calling `compile' with the last compile command which is
;; asked to be edited by user ...
;; The `kill-compile' command is then bound dynamically (buffer-local).
;;
;; @@ compilation-mode:
;; Call `compile' with the last compile command.
;;
;; @@ makefile-mode:
;; The makefile is run with make throught `compile' (user is prompted
;; for the rule to run, see variable
;; `mode-compile-prefered-default-makerule' to see how a default choice
;; could be selected).
;;
;; @@ emacs-lisp-mode, lisp-interaction-mode:
;; If the buffer is a .el file byte-compile it to produce a .elc file,
;; else just byte-compile the buffer (this don't use `compile' but
;; `byte-compile').
;;
;; @@ dired-mode:
;; Find a makefile in the directory and run make with it (like in
;; makefile-mode), else try to byte-recompile all .el files olders than
;; their associated .elc files (unlike `byte-recompile-directory' this is
;; not recursive), finally if no .el files are present ask compilation
;; command to user by calling `default-compile'. To find a makefile a
;; regexp is provided which name is `mode-compile-makefile-regexp'.
;;
;; @@ sh-mode, csh-mode, zsh-mode:
;; Run "[cz]?sh" with debugging arguments as specified in
;; `[cz]?sh-dbg-flags' on the currently edited file.
;;
;; @@ c?perl-mode:
;; Run file with "perl -w" (can step throught errors with compile's
;; `next-error' command).
;;
;; @@ tcl-mode:
;; Run file with "wish" (can step throught errors with compile's
;; `next-error' command).
;;
;; @@ c-mode, c++-mode:
;; First it try to see if there is a makefile in the directory, makefiles to
;; look for are specified by the variable `mode-compile-makefile-regexp'.
;; If yes two cases could happen: there is only one makefile so use it, or
;; there is more than one (sometimes when you need to write portable soft
;; you could have some makefiles by system: SunOs.make, HP.make ...), in
;; that case prompt to user for choice (with smart completion). Once the
;; makefile has been selected it extract the rules from it and ask to user
;; to choose a rule to make (with smart completion, see variable
;; `mode-compile-prefered- default-makerule' to see how a default choice
;; could be selected).
;;
;; There are some cases where no makefiles are presents (YES I KNOW this is
;; bad practice but you sometimes have no needs to write a Makefile). In
;; that case the function try to build the most intelligent compilation
;; command by using the favourite user C/C++ compiler: value of environment
;; variable "CC" or "CXX" or first found, in the PATH, of compilers
;; specified in variable `cc-compilers-list' or `c++-compilers-list'. Then
;; it look for the varenv "CFLAGS" of "CXXFLAGS" to append to the compiler
;; command, find the file to compile:
;; <name-of-the-file-to-compiled>.(c|cc|C|cpp) (see *) and ask for
;; confirmation. If you really trust mode-compile will build the right
;; command and want to bypass confirmation you could set the variable
;; `mode-compile-never-edit-command-p' to t.
;;
;; (*) How to find <name-of-the-file-to-compiled>:
;; In both case the command try to guess which file has to be compiled:
;; It's a trivial choice when current buffer file is a
;; .(c|C|cc|cpp... -any file with extension specified in
;; `cc-source-file-ext-list' or `c++-source-file-ext-list') file but
;; when it's a .(h|H|hh) file what to do? The variable
;; `cc-companion-file-regexp' or `c++-companion-file-regexp' specify
;; how to find a .(c|C|cc|cpp...) file from a .(h|H|hh...); This is
;; done by appending .(c|C|cc|cpp) to
;; <filename-without-matching-regexp>. In c-mode with default value
;; it produce:
;; file.h, file_[Pp].h -> file.c
;; I sometimes use files _p.h to indicate that the file is a private header
;; file for a .c file.
;; In c++-mode with default value it produce:
;; file.hh, file_[Pp].hh -> file.cc
;; I sometimes use files _p.cc to indicate that the file is a private header
;; file for a .cc file.
;; The output of compilation will be a
;; <name-of-the-file-to-compiled>.o file if no `main' function is
;; found inside or a <name-of-the-file-to-compiled> EXECUTABLE file
;; if `main' function found.
;;
;; @@ ada-mode:
;; Same as c/c++-mode but run Ada compiler on the Ada file. There are no
;; companion file and no way to find a main function in Ada.
;;
;; @@ fortran-mode:
;; Same as c-mode but run Fortran compiler on .[Ff](or)? files.
;;
;; @@ java-mode:
;; Same as c-mode but call "javac" without the -o option on .java files
;;
;; @@ python-mode:
;; Run file with "python" (can step throught errors with compile's
;; `next-error' command).
;;
;; @@ ruby-mode:
;; Run file with "ruby" (can step throught errors with compile's
;; `next-error' command).
;;
;; @@ message-mode:
;; Run `message-send'.
;;
;; @ WhatsNew:
;; ===========
;;
;; Support for ruby-mode
;;
;; @ Contributors/Helpers:
;; =======================
;;
;; Adrian Aichner <[email protected]>
;; "William A. Perkins" <[email protected]>
;; Bin Mu <[email protected]>
;; Gael MARZIOU <[email protected]>
;; Christian Motschke <[email protected]>
;; boris <[email protected]>
;; Edward Hartnett <[email protected]>.
;; Hartmut MANZ <[email protected]>.
;; Henry Guillaume <[email protected]>.
;; Ian Young <[email protected]>
;; Ilya Zakharevich <[email protected]>.
;; Kevin Broadey <[email protected]>.
;; Lawrence R. Dodd <[email protected]>.
;; Martin Jost <[email protected]>.
;; Michael Welsh Duggan <[email protected]>.
;; Rolf EBERT <[email protected]>.
;; Scott Hofmann <[email protected]>.
;; Stefan Schoef <[email protected]>.
;; John W. Harwell <[email protected]> - JWH.
;; Charles L.G. Comstock <[email protected]> - CLGC
;;
;; @ ToDo:
;; =======
;;
;; Extending this to some others programming languages (modes).
;; Writting an Info documentation.
;; Contributors are greatly accepted (send me diffs and don't forget to
;; update documentation and all comments too please).
;; Maybe Using ange-ftp parse .netrc utilities for remote host and
;; user infos.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; @ Requirements ;;;
;; mode-compile is not a replacement for compile
;; it is just a layer above it.
(require 'compile)
;;; For Emacs-Lisp files compilations
(require 'byte-compile "bytecomp")
;;; For easy macros
(require 'backquote)
(require 'cl)
(load-library "cl-macs")
;; Pretty print elisp
(require 'pp)
;;; Setting obsolete vars
(eval-and-compile
(condition-case ()
(require 'obsolete)
(error nil))
(if (and (featurep 'obsolete) (fboundp 'define-obsolete-variable-alias))
nil ;; We've got what we needed
(defmacro define-obsolete-variable-alias (old new)
(` (progn (defalias (, old) (, new))
(put (, old) 'byte-obsolete-variable (, new)))
))))
;;; For using custom - stolen from w3-cus.el -
(eval-and-compile
(condition-case ()
(require 'custom)
(error nil))
(if (and (featurep 'custom) (fboundp 'custom-declare-variable))
nil ;; We've got what we needed
;; We have the old custom-library, hack around it!
(defmacro defgroup (&rest args)
nil)
(defmacro defcustom (var value doc &rest args)
(` (defvar (, var) (, value) (, doc))))))
;; Custom groups
(defgroup compilation nil
"Compilations from within Emacs variables."
:link '(url-link :tag "Author's Emacs Page"
"http://www.tls.cena.fr/~boubaker/Emacs/")
:group 'tools
:group 'development)
(defgroup compilation-lang nil
"Language specific compilation options."
:group 'languages
:group 'compilation)
(defgroup compilation-script nil
"Scripts compilation options."
:group 'compilation)
(defgroup compilation-elisp nil
"Emacs developpement compilation options."
:group 'lisp
:group 'compilation)
;; @ User variables ;;;
;; @@ Common variables to mode-compile for all modes ;;;
(defcustom mode-compile-modes-alist
'((c-mode . (cc-compile kill-compilation))
(java-mode . (java-compile kill-compilation))
(c++-mode . (c++-compile kill-compilation))
(ada-mode . (ada-compile kill-compilation))
(fortran-mode . (f77-compile kill-compilation))
(dired-mode . (dired-compile kill-compilation))
(emacs-lisp-mode . (elisp-compile keyboard-quit)) ; I'm SURE IT'S NOT the best way
(lisp-interaction-mode . (elisp-compile keyboard-quit)) ; to kill a byte-compilation.
(makefile-mode . (makefile-compile kill-compilation))
(sh-mode . (sh-compile kill-compilation))
(csh-mode . (csh-compile kill-compilation))
(zsh-mode . (zsh-compile kill-compilation))
(perl-mode . (perl-compile kill-compilation))
(cperl-mode . (perl-compile kill-compilation))
(tcl-mode . (tcl-compile kill-compilation)) ; JWH
(python-mode . (python-compile kill-compilation)) ; BM
(ruby-mode . (ruby-compile kill-compilation)) ; CLGC
;(message-mode . (message-compile kill-compilation))
(fundamental-mode . (guess-compile nil)) ; bound dynamically
(text-mode . (guess-compile nil)) ; itou
(indented-text-mode . (guess-compile nil)) ; itou
(compilation-mode . (default-compile kill-compilation)))
"Assoc list of compile/kill functions for some known modes.
Each element look like (MODE . (COMPILE-FUNCTION KILL-FUNCTION))
`mode-compile' will call COMPILE-FUNCTION and `mode-compile-kill'
KILL-FUNCTION if current major-mode is MODE.
If you want to add or modify a COMPILE-FUNCTION and it's associated
KILL-FUNCTION for MODE and don't want to hack `mode-compile' you could
do the following (it exists however a more subtle method for
modifying, this is left as an exercice for the reader :-):
(defun my-mode-compile() ...)
(defun my-mode-compile-kill() ...)
(setq mode-compile-modes-alist
(append '((my-mode . (my-mode-compile my-mode-compile-kill)))
mode-compile-modes-alist))"
:type '(repeat
(cons :tag "Association: mode/compilation functions"
(function :tag "Mode")
(list :tag "Compilation functions"
(choice :tag "Function to run the compilation"
(function-item :tag "Default" :value default-compile)
(function-item :tag "Guess" :value guess-compile)
(function-item :tag "Emacs lisp byte compilation" :value elisp-compile)
(function :tag "Your choice, take care..."))
(choice :tag "Function to kill a running compilation"
(function-item :tag "Just kill" :value kill-compilation)
(const :tag "Nothing -- use with guess-compile --" :value nil)
(function-item :tag "To use with elisp-compile" :value keyboard-quit)
;; This item could not be selected due to a custom (hum) feature ...
(function :tag "Your choice, take care..." :value nil)))))
:group 'compilation)
(defcustom mode-compile-filename-regexp-alist
;; These could be in auto-mode-alist. But if you are like me
;; and don't like these modes (prefear to edit these kind of
;; files in text-mode) this is a nice way to compile them
;; without to be bored with their associated modes.
'((mode-compile-makefile-regexp . makefile-mode)
("\\.sh$" . sh-mode)
("\\.csh$" . csh-mode)
("\\.zsh$" . zsh-mode))
"Assoc list of major-modes for some filenames regexp.
Each element look like (REGEXP . MODE) This variable is really similar
to `auto-mode-alist' in the fact that it associate a MODE to a REGEXP
matching a filename. The only differences is that you are not obliged
to have the specified MODE available to use it (`guess-compile' use
it), the MODE is only a pointer to an assoq in
`mode-compile-modes-alist' to get the COMPILE-FUNCTION and the
KILL-FUNCTION. The REGEXP could be a form wich evaluate to a string.
To add a new filename regexp do the following:
(setq mode-compile-filename-regexp-alist
(append '((my-filename-regexp . some-mode-mode-compile-know)
mode-compile-modes-alist))"
:type '(repeat
(cons :tag "Association: filename/mode"
(choice :tag "Filename regexp match"
(regexp :tag "Regexp as a string")
(symbol :tag "Variable containing the regexp")
(sexp :tag "Form wich evaluate to a string"))
;; I need to bind dynamicaly this with const, ideas??
;;`(choice
;; ,@(mapcar (lambda (x) `(const ,(car x))) mode-compile-modes-alist))))
(function :tag "Mode to use -- should be a valid assoq in mode-compile-modes-alist --")))
:group 'compilation)
(defcustom mode-compile-shell-alist
'(("sh" . sh-mode)
("csh" . csh-mode)
("zsh" . zsh-mode)
("perl" . perl-mode)
("tcl" . tcl-mode) ; JWH
("python" . python-mode) ; BM
("ruby" . ruby-mode)) ; CLGC
"Assoc list of compile function for some known shells.
Each element look like (SHELL . MODE) This variable look like
`auto-mode-alist' in the fact that it associate a MODE to a name; A
SHELL name here. The main difference is that you are not obliged to
have the specified MODE available to use it (`guess-compile' use it),
the MODE is only a pointer to an assoq in `mode-compile-modes-alist'
to get the COMPILE-FUNCTION and the KILL-FUNCTION.
To add a new shell do the following:
(setq mode-compile-filename-shell-alist
(append '((my-shell-name . some-mode-mode-compile-know)
mode-compile-modes-alist))"
:type '(repeat
(cons :tag "Association: shell name/mode"
(string :tag "Shell name")
;; I need to bind dynamicaly this with const, ideas??
;;`(choice
;; ,@(mapcar (lambda (x) `(const ,(car x))) mode-compile-modes-alist))))
(function :tag "Mode to use -- should be a valid assoq in mode-compile-modes-alist --")))
:group 'compilation)
;;;###autoload
(defcustom mode-compile-make-program "make"
"*The `make' program used to process makefiles.
If you have GNU make installed with name \"gmake\" use it."
:type 'string
:group 'compilation)
(defcustom mode-compile-makefile-regexp
"\\(^[Mm]akefile\\|.*\\.[mM][aA]?[kK][eE]?\\.?.*$\\)"
"Regexp matching 'could be' makefiles filenames."
:type 'regexp
:group 'compilation)
(defcustom mode-compile-makefile-backups-regexp
"\\(\\(~\\|\\.[bB][aA][cC]?[kK]\\)$\\)\\|\\(\\(^\\|/\\)[.,][^/]+$\\)"
"Regexp to find if a Makefile is a backup or not"
:type 'regexp
:group 'compilation)
;;;###autoload
(defcustom mode-compile-ignore-makefile-backups t
"*Tell mode compile to ignore makefiles backup files when selecting the Makefile to use."
:type 'boolean
:group 'compilation)
;;;###autoload
(defvar mode-compile-default-make-options "-k"
"Default options to give to `make'.")
;;;###autoload
(defcustom mode-compile-make-options (eval mode-compile-default-make-options)
"*Options to give to `make'.
This could be any form evaluating to a string.
Some people asked me a way to modify the make options everytime a
compilation command is launched, do that:
(defun my-mode-compile-ask-make-options()
\"*Hook called by mode-compile, asking for make options.\"
(interactive)
(read-string \"Make options: \"
mode-compile-default-make-options))
(setq mode-compile-make-options
'my-mode-compile-ask-make-options)"
:type '(choice
string
(sexp :tag "Form evaluating to a string"))
:group 'compilation)
;;;###autoload
(defcustom mode-compile-prefered-default-makerule 'none
"*Default makerule you would like to see in minibuffer as a default choice
when selecting the make rule to build.
Possible values are:
'none -- let mode-compile deciding for you.
'all -- try hard to show you the \"all\" rule.
'default -- try hard to show you the \"default\" rule.
'file -- try to show you the name of the file which will be
result of compilation.
The 'none action is taken as default is something fail."
:type '(radio :tag "Symbol"
(const :tag "None - Let mode compile made the choice" :value none)
(const :tag "All - Show the \"all\" rule" :value all)
(const :tag "Default - Show the \"default\" rule" :value default)
(const :tag "File - Show the \"result file name\" rule" :value file))
:group 'compilation)
;;;###autoload
(defcustom mode-compile-ignore-makerule-regexp nil
"*Makefile rules which must be ignored when building completion list.
For example if you want to remove all `files rules' set
it to: \"\\\\.\\\\([aoc]\\\\|s[ao][.0-9]*\\\\)\". "
:type '(choice (const :tag "none" :value nil)
(const :tag "The `all files' rule" :value "\\.\\([aoc]\\|s[ao][.0-9]*\\)")
regexp)
:group 'compilation)
;;;###autoload
(defcustom mode-compile-save-all-p nil
"*Non-nil means save ALL the modified buffers without asking
before launching compilation command."
:type 'boolean
:group 'compilation)
;;;###autoload
(defcustom mode-compile-always-save-buffer-p nil
"*Non-nil means save the current buffer without asking
before launching compilation command."
:type 'boolean
:group 'compilation)
;;;###autoload
(defcustom mode-compile-never-edit-command-p nil
"*Non-nil means never ask to user to edit the compile command."
:type 'boolean
:group 'compilation)
;; @@ Compilation in other frame vars ;;;
(defgroup compilation-frame nil
"Compile in another frame variables."
:group 'frames
:group 'compilation)
;;;###autoload
(defcustom mode-compile-other-frame-p nil
"*Non-nil means compile in another frame.
A new Emacs FRAME is created and the compilation command is executed
in this other frame. To specify the frame parameters see also
variable `mode-compile-frame-parameters-alist'."
:type 'boolean
:group 'compilation-frame)
(defcustom mode-compile-other-frame-name "COMPILATION"
"Name of mode-compile's other frame.
This name could be used in your .Xdefault or .Xresources file as:
Emacs.MODE-COMPILE-OTHER-FRAME-NAME.resource_to_be_set: ..."
:type 'string
:group 'compilation-frame)
(defconst mode-compile-default-frame-parameters
(list
(cons 'name mode-compile-other-frame-name)
(cons 'width 85) ; columns
(cons 'height 30)) ; lines
"Default parameters for mode-compile's other frame.")
(defvar mode-compile-frame-parameters-alist
(purecopy mode-compile-default-frame-parameters)
"Parameters for the new Compilation Screen created
if variable `mode-compile-other-frame-p' is non nil..
See also variable `mode-compile-default-frame-parameters' and
`mode-compile-other-frame-name'.
For informations about Screen/Frame parameters see:
- Info, Nodes: Lispref::Screen::Screen Parameters
- GNU Emacs Lisp Reference Manual, chapter 26 p375: Frames.")
;; @@ Hooks ;;;
;;;###autoload
(defcustom mode-compile-before-compile-hook nil
"Hook to be run before compile command is executed
when `mode-compile' is invoked."
:type 'hook
:group 'compilation)
;;;###autoload
(defcustom mode-compile-after-compile-hook nil
"Hook to be run after compile command is executed
when `mode-compile' is invoked."
:type 'hook
:group 'compilation)
;;;###autoload
(defcustom mode-compile-before-kill-hook nil
"Hook to be run before killing compile command is executed
when `mode-compile-kill' is invoked."
:type 'hook
:group 'compilation)
;;;###autoload
(defcustom mode-compile-after-kill-hook nil
"Hook to be run after killing compile command is executed
when `mode-compile-kill' is invoked."
:type 'hook
:group 'compilation)
;; @@ System dependencies ;;;
(defvar mode-compile-exe-file-ext
(cond
((memq system-type '(ms-dos emx windows-95 windows-98 windows-nt)) ".exe")
(t ""))
"*Extension of executable files (with dot included)")
(defvar mode-compile-dir-separator-char
(cond
;; MSDOSish file systems
((memq system-type '(ms-dos emx windows-95 windows-98 windows-nt)) "\\")
;; Unixish file systems
(t "/"))
"*Separator char between directories")
;; @@ Facilities variables ;;;
;;;###autoload
(defvar mode-compile-choosen-compiler nil
"*Global variable containing the name of the compiler
which will be used for compiling without makefile.
Could be used in combination with
(cc|c++|ada|f77)-default-compiler-options
to automaticaly choose the compiler specific options.
example:
(defun my-compiler-get-options()
(cond
((string= mode-compile-choosen-compiler \"gcc\")
\"-Wall -pedantic-errors\")
((string= mode-compile-choosen-compiler \"cc\")
\"cc options whatever they are...\")
(t
(message \"Don't know this compiler: %s\" mode-compile-choosen-compiler)
(read-string
(format \"Options for %s compiler: \" mode-compile-choosen-compiler)))))
(setq cc-default-compiler-options 'my-compiler-get-options)")
;; @@ User level ;;;
;;;###autoload
(defcustom mode-compile-expert-p nil
"*Non nil means `mode-compile' will not speaks too much.
See also variable variable mode-compile-reading-time."
:type 'boolean
:group 'compilation)
;;;###autoload
(defcustom mode-compile-reading-time 1
"*Seconds to wait in verbose mode after printing a message.
In verbose mode mode-compile print too much messages that it is
allmost impossible to read them. Just setting this delay leave you the
time to read all the messages. If you don't want any delay set it to
`0'.
See also function sit-for."
:type 'integer
:group 'compilation)
;; @@ Remote compilation vars ;;;
(defgroup compilation-remote nil
"Remote compilations options."
:group 'compilation)
(defcustom mode-compile-remote-hosts-alist '()
"Alist of favourites hosts names and the username
to use to log on (HOSTNAME . USERNAME).
If USERNAME is a function it will be called with HOSTNAME as argument
and should return an USERNAME string (for example you could use
something like efs-get-user - not tested -), if it is nil the function
user-login-name will be used."
:type '(repeat
(cons
(string :tag "Hostname")
(choice
(const :tag "We'll use \'user-login-name" :value nil)
(string :tag "Username")
(function :tag "Function which return USERNAME given a HOSTNAME" :value efs-get-user))))
:group 'compilation-remote)
(defcustom mode-compile-remote-execute-command "rsh"
"The shell command used to run a command remotely.
\"rsh\" is the only choice I know but I'm far to know everything...
This variable is set automaticaly with the value of
remote-shell-program or efs-remote-shell-file-name at load time."
:type 'string
:group 'compilation)
(eval-when 'load
(cond
((not (string= mode-compile-remote-execute-command "rsh"))
;; user changed default
nil)
;; Try to not multiply definitions of the same stuff
;; in too many emacs lisp packages ...
((and (boundp 'remote-shell-program) remote-shell-program)
(setq mode-compile-remote-execute-command remote-shell-program))
((and (boundp 'efs-remote-shell-file-name) efs-remote-shell-file-name)
(setq mode-compile-remote-execute-command efs-remote-shell-file-name))
))
(defcustom mode-compile-remote-execute-set-host-arg ""
"Argument To set the remote host name to the
mode-compile-remote-execute-command,
None is required for \"rsh\"."
:type 'string
:group 'compilation-remote)
(defcustom mode-compile-remote-execute-set-command-arg ""
"Argument to set the command to be run remotely to the
mode-compile-remote-execute-command.
None is required for \"rsh\"."
:type 'string
:group 'compilation-remote)
(defcustom mode-compile-remote-execute-set-username-arg "-l"
"Argument to set the username under which we will log on
on the remote host, to give to mode-compile-remote-execute-command."
:type 'string
:group 'compilation-remote)
(defcustom mode-compile-remote-execute-misc-args ""
"Misc additionnals arguments to give to the
mode-compile-remote-execute-command."
:type 'string
:group 'compilation-remote)
;; @@ c-mode compile variables ;;;
(defgroup compile-c nil
"C Compilation options."
:group 'c
:group 'compilation-lang)
(defcustom cc-compilers-list '( "gcc" "c89" "acc" "cc" )
"List of user's favourites C compilers in order of preferencies."
:type '(repeat (string :tag "C Compiler name"))
:group 'compile-c)
(defcustom cc-companion-file-regexp "\\(_[Pp]\\)?\\.[pP]?h"
"Regexp to find associated .c file from a .h."
:type 'regexp
:group 'compile-c)
(defcustom cc-default-compiler "cc"
"*Default C compiler to use when everything else fails.
This could be any form evaluating to a string, so you could map it to
a function asking you interactively to choose the compiler.
example:
(defun my-choose-compiler()
(read-string \"C compiler: \"))
(setq cc-compilers-list '()
cc-default-compiler 'my-choose-compiler)"
:type '(choice string function)
:group 'compile-c)
(defcustom cc-compiler-varenv "CC"
"Varenv indicating the C compiler to use."
:type 'string
:group 'compile-c)
(defcustom cc-cflags-varenv "CFLAGS"
"Varenv indicating the C compiler flags to use."
:type 'string
:group 'compile-c)
(defcustom cc-source-ext-list '( "c" )
"Extensions for C compileable source files."
:type '(repeat string)
:group 'compile-c)
(defcustom cc-headers-ext-list '( "h" )
"Extensions for C headers source files."
:type '(repeat string)
:group 'compile-c)
(defcustom cc-default-compiler-options "-g"
"*Default options to give to the C compiler.
This could be any form evaluating to a string.
See `mode-compile-choosen-compiler' variable."
:type '(choice
string
(sexp :tag "Form evaluating to a string"))
:group 'compile-c)
(defcustom cc-source-file-ext-regexp "\\.c"
"Regexp to find, from it's name, if a C file is compileable."
:type 'string
:group 'compile-c)
(defcustom cc-build-output-args t
"Build output-args for c-mode."
:type 'boolean
:group 'compile-c)
(defcustom cc-object-file-ext "o"
"Extension of objects file (result of compilation)
in c mode."
:type 'string
:group 'compile-c)
;; @@ java-mode compile variables ;;;
(defgroup compile-java nil
"Java compilation options."
:group 'compilation-lang)
(defcustom java-compilers-list '( "javac" )
"List of user's favourites java compilers in order of preferencies."
:type '(repeat (string :tag "Java Compiler name"))
:group 'compile-java)
(defcustom java-companion-file-regexp ""
"Regexp to find associated compileable Java companion file.
This is useless in Java because there do not exists uncompileable files."
:type 'regexp
:group 'compile-java)
(defcustom java-default-compiler "javac"
"*Default C compiler to use when everything else fails.
This could be any form evaluating to a string, so you could map it to
a function asking you interactively to choose the compiler.
example:
(defun my-choose-compiler()
(read-string \"Java compiler: \"))
(setq java-default-compiler 'my-choose-compiler)."
:type '(choice string function)
:group 'compile-java)
(defcustom java-compiler-varenv "JAVAC"
"Varenv indicating the C compiler to use."
:type 'string
:group 'compile-java)
(defcustom java-cflags-varenv "JAVAC_FLAGS"
"Varenv indicating the C compiler flags to use."
:type 'string
:group 'compile-java)
(defcustom java-source-ext-list '( "java" )
"Extensions for Java compileable source files."
:type '(repeat string)
:group 'compile-java)
(defcustom java-headers-ext-list '( "java" )
"Extensions for Java source files."
:type '(repeat string)
:group 'compile-java)
(defcustom java-default-compiler-options "-O"
"*Default options to give to the Java compiler.
This could be any form evaluating to a string. See
`mode-compile-choosen-compiler' variable."
:type '(choice
string
(sexp :tag "Form evaluating to a string"))
:group 'compile-java)
(defcustom java-source-file-ext-regexp "\\.java"
"Regexp to find, from it's name, if a Java file is compileable."
:type 'regexp
:group 'compile-java)
(defcustom java-build-output-args nil
"Dont build output-args for Java-mode."
:type 'boolean
:group 'compile-java)
(defcustom java-object-file-ext "class"
"Extension of objects file (result of compilation)
in java mode."
:type 'string
:group 'compile-java)
;; @@ c++-mode compile variables ;;;
(defgroup compile-c++ nil
"C++ compilation options"
:group 'compilation-lang)
(defcustom c++-compilers-list '( "g++" "gcc" "CC" )
"List of user's favourites C++ compilers in order of preferencies."
:type '(repeat (string :tag "C++ Compiler name"))
:group 'compile-c++)
(defcustom c++-companion-file-regexp "\\(_[Pp]\\)?\\.\\([pP]?[Hh][Hh]?\\|[Hh]\\+\\+?\\)"
"Regexp to find associated compileable C++ companion file
from a header file."
:type 'regexp
:group 'compile-c++)
(defcustom c++-default-compiler "CC"
"*Default C++ compiler to use when everything else fails..
This could be any form evaluating to a string, so you could map it to
a function asking you interactively to choose the compiler.
example:
(defun my-choose-compiler()
(read-string \"C++ compiler: \"))
(setq c++-default-compiler 'my-choose-compiler)"
:type '(choice string function)
:group 'compile-c++)
(defcustom c++-compiler-varenv "CXX"
"Varenv indicating the C++ compiler to use."
:type 'string
:group 'compile-c++)
(defcustom c++-cflags-varenv "CXXFLAGS"
"Varenv indicating the C++ compiler flags to use."
:type 'string
:group 'compile-c++)
(defcustom c++-source-ext-list '( "cc" "C" "CC" "cpp" "cxx" "c++" "c+" )
"Extensions for C++ compileable source files."
:type '(repeat string)
:group 'compile-c++)
(defcustom c++-headers-ext-list '( "H" "hh" "HH" "h++" "h+" "h" "hpp" "hxx" )
"Extensions for C++ headers source files."
:type '(repeat string)
:group 'compile-c++)
(defcustom c++-default-compiler-options "-g"
"*Default options to give to the C++ compiler.
This could be any form evaluating to a string. See
`mode-compile-choosen-compiler' variable."
:type '(choice
string
(sexp :tag "Form evaluating to a string"))
:group 'compile-c++)
(defcustom c++-source-file-ext-regexp "\\.\\(cc\\|CC?\\|c\\+\\+?\\|cpp\\|cxx\\)"
"Regexp to find, from it's name, if a C++ file is compileable."
:type 'regexp
:group 'compile-c++)
(defcustom c++-build-output-args t
"Build output-args for c++-mode."
:type 'boolean
:group 'compile-c++)
(defcustom c++-object-file-ext "o"
"Extension of objects file (result of compilation)
in c++ mode."
:type 'string
:group 'compile-c++)
;; @@ ada-mode compile variables ;;;
(defgroup compile-ada nil
"Ada compilation options"
:group 'compilation-lang)
(defcustom ada-compilers-list
'( "gcc" "gnat" "ada" )
"List of user's favourites Ada compilers in order of preferencies."
:type '(repeat (string :tag "Ada Compiler name"))
:group 'compile-ada)
(defcustom ada-companion-file-regexp ""
"Regexp to find associated compileable Ada companion file from a spec file.
This is useless in Ada because there do not exists uncompileable files."
:type 'regexp
:group 'compile-ada)
(defcustom ada-default-compiler "ada"
"*Default Ada compiler to use when everything else fails.