forked from erlang/otp
/
erlang.el
5678 lines (4939 loc) · 189 KB
/
erlang.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
;; erlang.el --- Major modes for editing and running Erlang
;; %CopyrightBegin%
;;
;; Copyright Ericsson AB 1996-2012. All Rights Reserved.
;;
;; The contents of this file are subject to the Erlang Public License,
;; Version 1.1, (the "License"); you may not use this file except in
;; compliance with the License. You should have received a copy of the
;; Erlang Public License along with this software. If not, it can be
;; retrieved online at http://www.erlang.org/.
;;
;; Software distributed under the License is distributed on an "AS IS"
;; basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
;; the License for the specific language governing rights and limitations
;; under the License.
;;
;; %CopyrightEnd%
;;
;; Copyright (C) 2004 Free Software Foundation, Inc.
;; Author: Anders Lindgren
;; Keywords: erlang, languages, processes
;; Lars Thorsén's modifications of 2000-06-07 included.
;; The original version of this package was written by Robert Virding.
;;
;;; Commentary:
;; Introduction:
;; ------------
;;
;; This package provides support for the programming language Erlang.
;; The package provides an editing mode with lots of bells and
;; whistles, compilation support, and it makes it possible for the
;; user to start Erlang shells that run inside Emacs.
;;
;; See the Erlang distribution for full documentation of this package.
;; Installation:
;; ------------
;;
;; Place this file in Emacs load path, byte-compile it, and add the
;; following line to the appropriate init file:
;;
;; (require 'erlang-start)
;;
;; The full documentation contains much more extensive description of
;; the installation procedure.
;; Reporting Bugs:
;; --------------
;;
;; Please send bug reports to the following email address:
;; erlang-bugs@erlang.org
;; or if you have a patch suggestion to:
;; erlang-patches@erlang.org
;; Please state as exactly as possible:
;; - Version number of Erlang Mode (see the menu), Emacs, Erlang,
;; and of any other relevant software.
;; - What the expected result was.
;; - What you did, preferably in a repeatable step-by-step form.
;; - A description of the unexpected result.
;; - Relevant pieces of Erlang code causing the problem.
;; - Personal Emacs customisations, if any.
;;
;; Should the Emacs generate an error, please set the Emacs variable
;; `debug-on-error' to `t'. Repeat the error and enclose the debug
;; information in your bug-report.
;;
;; To set the variable you can use the following command:
;; M-x set-variable RET debug-on-error RET t RET
;;; Code:
;; Variables:
(defconst erlang-version "2.7"
"The version number of Erlang mode.")
(defvar erlang-root-dir nil
"The directory where the Erlang system is installed.
The name should not contain the trailing slash.
Should this variable be nil, no manual pages will show up in the
Erlang mode menu.")
(eval-and-compile
(defconst erlang-emacs-major-version
(if (boundp 'emacs-major-version)
emacs-major-version
(string-match "\\([0-9]+\\)\\.\\([0-9]+\\)" emacs-version)
(erlang-string-to-int (substring emacs-version
(match-beginning 1) (match-end 1))))
"Major version number of Emacs."))
(eval-and-compile
(defconst erlang-emacs-minor-version
(if (boundp 'emacs-minor-version)
emacs-minor-version
(string-match "\\([0-9]+\\)\\.\\([0-9]+\\)" emacs-version)
(erlang-string-to-int (substring emacs-version
(match-beginning 2) (match-end 2))))
"Minor version number of Emacs."))
(defconst erlang-xemacs-p (string-match "Lucid\\|XEmacs" emacs-version)
"Non-nil when running under XEmacs or Lucid Emacs.")
(defvar erlang-xemacs-popup-menu '("Erlang Mode Commands" . nil)
"Common popup menu for all buffers in Erlang mode.
This variable is destructively modified every time the Erlang menu
is modified. The effect is that all changes take effect in all
buffers in Erlang mode, just like under GNU Emacs.
Never EVER set this variable!")
(defvar erlang-menu-items '(erlang-menu-base-items
erlang-menu-skel-items
erlang-menu-shell-items
erlang-menu-compile-items
erlang-menu-man-items
erlang-menu-personal-items
erlang-menu-version-items)
"*List of menu item list to combine to create Erlang mode menu.
External programs which temporarily add menu items to the Erlang mode
menu may use this variable. Please use the function `add-hook' to add
items.
Please call the function `erlang-menu-init' after every change to this
variable.")
(defvar erlang-menu-base-items
'(("Indent"
(("Indent Line" erlang-indent-command)
("Indent Region " erlang-indent-region
(if erlang-xemacs-p (mark) mark-active))
("Indent Clause" erlang-indent-clause)
("Indent Function" erlang-indent-function)
("Indent Buffer" erlang-indent-current-buffer)))
("Edit"
(("Fill Comment" erlang-fill-paragraph)
("Comment Region" comment-region
(if erlang-xemacs-p (mark) mark-active))
("Uncomment Region" erlang-uncomment-region
(if erlang-xemacs-p (mark) mark-active))
nil
("Beginning of Function" erlang-beginning-of-function)
("End of Function" erlang-end-of-function)
("Mark Function" erlang-mark-function)
nil
("Beginning of Clause" erlang-beginning-of-clause)
("End of Clause" erlang-end-of-clause)
("Mark Clause" erlang-mark-clause)
nil
("New Clause" erlang-generate-new-clause)
("Clone Arguments" erlang-clone-arguments)
nil
("Align Arrows" erlang-align-arrows)))
("Syntax Highlighting"
(("Level 4" erlang-font-lock-level-4)
("Level 3" erlang-font-lock-level-3)
("Level 2" erlang-font-lock-level-2)
("Level 1" erlang-font-lock-level-1)
("Off" erlang-font-lock-level-0)))
("TAGS"
(("Find Tag" find-tag)
("Find Next Tag" erlang-find-next-tag)
;("Find Regexp" find-tag-regexp)
("Complete Word" erlang-complete-tag)
("Tags Apropos" tags-apropos)
("Search Files" tags-search))))
"Description of menu used in Erlang mode.
This variable must be a list. The elements are either nil representing
a horizontal line or a list with two or three elements. The first is
the name of the menu item, the second is the function to call, or a
submenu, on the same same form as ITEMS. The third optional argument
is an expression which is evaluated every time the menu is displayed.
Should the expression evaluate to nil the menu item is ghosted.
Example:
'((\"Func1\" function-one)
(\"SubItem\"
((\"Yellow\" function-yellow)
(\"Blue\" function-blue)))
nil
(\"Region Function\" spook-function midnight-variable))
Call the function `erlang-menu-init' after modifying this variable.")
(defvar erlang-menu-shell-items
'(nil
("Shell"
(("Start New Shell" erlang-shell)
("Display Shell" erlang-shell-display))))
"Description of the Shell menu used by Erlang mode.
Please see the documentation of `erlang-menu-base-items'.")
(defvar erlang-menu-compile-items
'(("Compile"
(("Compile Buffer" erlang-compile)
("Display Result" erlang-compile-display)
("Next Error" erlang-next-error))))
"Description of the Compile menu used by Erlang mode.
Please see the documentation of `erlang-menu-base-items'.")
(defvar erlang-menu-version-items
'(nil
("Version" erlang-version))
"Description of the version menu used in Erlang mode.")
(defvar erlang-menu-personal-items nil
"Description of personal menu items used in Erlang mode.
Please see the variable `erlang-menu-base-items' for a description
of the format.")
(defvar erlang-menu-man-items nil
"The menu containing man pages.
The format of the menu should be compatible with `erlang-menu-base-items'.
This variable is added to the list of Erlang menus stored in
`erlang-menu-items'.")
(defvar erlang-menu-skel-items '()
"Description of the menu containing the skeleton entries.
The menu is in the form described by the variable `erlang-menu-base-items'.")
(defvar erlang-mode-hook nil
"*Functions to run when Erlang mode is activated.
This hook is used to change the behaviour of Erlang mode. It is
normally used by the user to personalise the programming environment.
When used in a site init file, it could be used to customise Erlang
mode for all users on the system.
The functions added to this hook are run every time Erlang mode is
started. See also `erlang-load-hook', a hook which is run once,
when Erlang mode is loaded into Emacs, and `erlang-shell-mode-hook'
which is run every time a new inferior Erlang shell is started.
To use a hook, create an Emacs lisp function to perform your actions
and add the function to the hook by calling `add-hook'.
The following example binds the key sequence C-c C-c to the command
`erlang-compile' (normally bound to C-c C-k). The example also
activates Font Lock mode to fontify the buffer and adds a menu
containing all functions defined in the current buffer.
To use the example, copy the following lines to your `~/.emacs' file:
(add-hook 'erlang-mode-hook 'my-erlang-mode-hook)
(defun my-erlang-mode-hook ()
(local-set-key \"\\C-c\\C-c\" 'erlang-compile)
(if window-system
(progn
(setq font-lock-maximum-decoration t)
(font-lock-mode 1)))
(if (and window-system (fboundp 'imenu-add-to-menubar))
(imenu-add-to-menubar \"Imenu\")))")
(defvar erlang-load-hook nil
"*Functions to run when Erlang mode is loaded.
This hook is used to change the behaviour of Erlang mode. It is
normally used by the user to personalise the programming environment.
When used in a site init file, it could be used to customize Erlang
mode for all users on the system.
The difference between this hook and `erlang-mode-hook' and
`erlang-shell-mode-hook' is that the functions in this hook
is only called once, when the Erlang mode is loaded into Emacs
the first time.
Natural actions for the functions added to this hook are actions which
only should be performed once, and actions which should be performed
before starting Erlang mode. For example, a number of variables are
used by Erlang mode before `erlang-mode-hook' is run.
The following example sets the variable `erlang-root-dir' so that the
manual pages can be retrieved (note that you must set the value of
`erlang-root-dir' to match the location of Erlang on your system):
(add-hook 'erlang-load-hook 'my-erlang-load-hook)
(defun my-erlang-load-hook ()
(setq erlang-root-dir \"/usr/local/erlang\"))")
(defvar erlang-new-file-hook nil
"Functions to run when a new Erlang source file is being edited.
A useful function is `tempo-template-erlang-normal-header'.
\(This function only exists when the `tempo' package is available.)")
(defvar erlang-check-module-name 'ask
"*Non-nil means check that module name and file name agrees when saving.
If the value of this variable is the atom `ask', the user is
prompted. If the value is t the source is silently changed.")
(defvar erlang-electric-commands
'(erlang-electric-comma
erlang-electric-semicolon
erlang-electric-gt)
"*List of activated electric commands.
The list should contain the electric commands which should be active.
Currently, the available electric commands are:
`erlang-electric-comma'
`erlang-electric-semicolon'
`erlang-electric-gt'
`erlang-electric-newline'
Should the variable be bound to t, all electric commands
are activated.
To deactivate all electric commands, set this variable to nil.")
(defvar erlang-electric-newline-inhibit t
"*Set to non-nil to inhibit newline after electric command.
This is useful since a lot of people press return after executing an
electric command.
In order to work, the command must also be in the
list `erlang-electric-newline-inhibit-list'.
Note that commands in this list are required to set the variable
`erlang-electric-newline-inhibit' to nil when the newline shouldn't be
inhibited.")
(defvar erlang-electric-newline-inhibit-list
'(erlang-electric-semicolon
erlang-electric-comma
erlang-electric-gt)
"*Commands which can inhibit the next newline.")
(defvar erlang-electric-semicolon-insert-blank-lines nil
"*Number of blank lines inserted before header, or nil.
This variable controls the behaviour of `erlang-electric-semicolon'
when a new function header is generated. When nil, no blank line is
inserted between the current line and the new header. When bound to a
number it represents the number of blank lines which should be
inserted.")
(defvar erlang-electric-semicolon-criteria
'(erlang-next-lines-empty-p
erlang-at-keyword-end-p
erlang-at-end-of-function-p)
"*List of functions controlling `erlang-electric-semicolon'.
The functions in this list are called, in order, whenever a semicolon
is typed. Each function in the list is called with no arguments,
and should return one of the following values:
nil -- no determination made, continue checking
'stop -- do not create prototype for next line
(anything else) -- insert prototype, and stop checking
If every function in the list is called with no determination made,
then no prototype is inserted.
The test is performed by the function `erlang-test-criteria-list'.")
(defvar erlang-electric-comma-criteria
'(erlang-stop-when-inside-argument-list
erlang-stop-when-at-guard
erlang-next-lines-empty-p
erlang-at-keyword-end-p
erlang-at-end-of-clause-p
erlang-at-end-of-function-p)
"*List of functions controlling `erlang-electric-comma'.
The functions in this list are called, in order, whenever a comma
is typed. Each function in the list is called with no arguments,
and should return one of the following values:
nil -- no determination made, continue checking
'stop -- do not create prototype for next line
(anything else) -- insert prototype, and stop checking
If every function in the list is called with no determination made,
then no prototype is inserted.
The test is performed by the function `erlang-test-criteria-list'.")
(defvar erlang-electric-arrow-criteria
'(erlang-stop-when-in-type-spec
erlang-next-lines-empty-p
erlang-at-end-of-function-p)
"*List of functions controlling the arrow aspect of `erlang-electric-gt'.
The functions in this list are called, in order, whenever a `>'
is typed. Each function in the list is called with no arguments,
and should return one of the following values:
nil -- no determination made, continue checking
'stop -- do not create prototype for next line
(anything else) -- insert prototype, and stop checking
If every function in the list is called with no determination made,
then no prototype is inserted.
The test is performed by the function `erlang-test-criteria-list'.")
(defvar erlang-electric-newline-criteria
'(t)
"*List of functions controlling `erlang-electric-newline'.
The electric newline commands indents the next line. Should the
current line begin with a comment the comment start is copied to
the newly created line.
The functions in this list are called, in order, whenever a comma
is typed. Each function in the list is called with no arguments,
and should return one of the following values:
nil -- no determination made, continue checking
'stop -- do not create prototype for next line
(anything else) -- trigger the electric command.
If every function in the list is called with no determination made,
then no prototype is inserted. Should the atom t be a member of the
list, it is treated as a function triggering the electric command.
The test is performed by the function `erlang-test-criteria-list'.")
(defvar erlang-next-lines-empty-threshold 2
"*Number of blank lines required to activate an electric command.
Actually, this value controls the behaviour of the function
`erlang-next-lines-empty-p' which normally is a member of the
criteria lists controlling the electric commands. (Please see
the variables `erlang-electric-semicolon-criteria' and
`erlang-electric-comma-criteria'.)
The variable is bound to a threshold value, a number, representing the
number of lines which must be empty.
Setting this variable to zero, electric commands will always be
triggered by `erlang-next-lines-empty-p', unless inhibited by other
rules.
Should this variable be nil, `erlang-next-lines-empty-p' will never
trigger an electric command. The same effect would be reached if the
function `erlang-next-lines-empty-p' would be removed from the criteria
lists.
Note that even if `erlang-next-lines-empty-p' should not trigger an
electric command, other functions in the criteria list could.")
(defvar erlang-new-clause-with-arguments nil
"*Non-nil means that the arguments are cloned when a clause is generated.
A new function header can be generated by calls to the function
`erlang-generate-new-clause' and by use of the electric semicolon.")
(defvar erlang-compile-use-outdir t
"*When nil, go to the directory containing source file when compiling.
This is a workaround for a bug in the `outdir' option of compile. If the
outdir is not in the current load path, Erlang doesn't load the object
module after it has been compiled.
To activate the workaround, place the following in your `~/.emacs' file:
(setq erlang-compile-use-outdir nil)")
(defvar erlang-indent-level 4
"*Indentation of Erlang calls/clauses within blocks.")
(put 'erlang-indent-level 'safe-local-variable 'integerp)
(defvar erlang-indent-guard 2
"*Indentation of Erlang guards.")
(put 'erlang-indent-guard 'safe-local-variable 'integerp)
(defvar erlang-argument-indent 2
"*Indentation of the first argument in a function call.
When nil, indent to the column after the `(' of the
function.")
(put 'erlang-argument-indent 'safe-local-variable '(lambda (val) (or (null val) (integerp val))))
(defvar erlang-indent-arguments-from-line-start nil
"*If non-nil, `erlang-argument-indent' applies from start of previous line.
Otherwise, it applies from the start of the function name.
That is, for an `erlang-argument-indent' of 8, setting this
variable to t will get you this:
case myfunction(
bar) of
...
instead of this:
case myfunction(
bar) of
...")
(put 'erlang-indent-arguments-from-line-start 'safe-local-variable 'booleanp)
(defvar erlang-tab-always-indent t
"*Non-nil means TAB in Erlang mode should always re-indent the current line,
regardless of where in the line point is when the TAB command is used.")
(defvar erlang-man-inhibit (eq system-type 'windows-nt)
"Inhibit the creation of the Erlang Manual Pages menu.
The Windows distribution of Erlang does not include man pages, hence
there is no attempt to create the menu.")
(defvar erlang-man-dirs
'(("Man - Commands" "/man/man1" t)
("Man - Modules" "/man/man3" t)
("Man - Files" "/man/man4" t)
("Man - Applications" "/man/man6" t))
"*The man directories displayed in the Erlang menu.
Each item in the list should be a list with three elements, the first
the name of the menu, the second the directory, and the last a flag.
Should the flag the nil, the directory is absolute, should it be non-nil
the directory is relative to the variable `erlang-root-dir'.")
(defvar erlang-man-max-menu-size 35
"*The maximum number of menu items in one menu allowed.")
(defvar erlang-man-display-function 'erlang-man-display
"*Function used to display man page.
The function is called with one argument, the name of the file
containing the man page. Use this variable when the default
function, `erlang-man-display', does not work on your system.")
(defvar erlang-compile-extra-opts '()
"*Additional options to the compilation command.
This is an elisp list of options. Each option can be either:
- an atom
- a dotted pair
- a string
Example: '(bin_opt_info (i . \"/path1/include\") (i . \"/path2/include\"))")
(defvar erlang-compile-command-function-alist
'((".erl\\'" . inferior-erlang-compute-erl-compile-command)
(".xrl\\'" . inferior-erlang-compute-leex-compile-command)
(".yrl\\'" . inferior-erlang-compute-yecc-compile-command)
("." . inferior-erlang-compute-erl-compile-command))
"*Alist of filename patterns vs corresponding compilation functions.
Each element looks like (REGEXP . FUNCTION). Compiling a file whose name
matches REGEXP specifies FUNCTION to use to compute the compilation
command. The FUNCTION will be called with two arguments: module name and
default compilation options, like output directory. The FUNCTION
is expected to return a string.")
(defvar erlang-leex-compile-opts '()
"*Options to pass to leex when compiling xrl files.
This is an elisp list of options. Each option can be either:
- an atom
- a dotted pair
- a string")
(defvar erlang-yecc-compile-opts '()
"*Options to pass to yecc when compiling yrl files.
This is an elisp list of options. Each option can be either:
- an atom
- a dotted pair
- a string")
(eval-and-compile
(defvar erlang-regexp-modern-p
(if (> erlang-emacs-major-version 21) t nil)
"Non-nil when this version of Emacs uses a modern version of regexp.
Supporting \_< and \_> This is determined by checking the version of Emacs used."))
(eval-and-compile
(defconst erlang-atom-quoted-regexp
"'\\(?:[^\\']\\|\\(?:\\\\.\\)\\)*'"
"Regexp describing a single-quoted atom"))
(eval-and-compile
(defconst erlang-atom-regular-regexp
(if erlang-regexp-modern-p
"\\_<[[:lower:]]\\(?:\\sw\\|\\s_\\)*\\_>"
"\\<[[:lower:]]\\(?:\\sw\\|\\s_\\)*\\>")
"Regexp describing a regular (non-quoted) atom"))
(eval-and-compile
(defconst erlang-atom-regexp
(concat "\\(" erlang-atom-quoted-regexp "\\|"
erlang-atom-regular-regexp "\\)")
"Regexp describing an Erlang atom."))
(eval-and-compile
(defconst erlang-atom-regexp-matches 1
"Number of regexp parenthesis pairs in `erlang-atom-regexp'.
This is used to determine parenthesis matches in complex regexps which
contains `erlang-atom-regexp'."))
(eval-and-compile
(defconst erlang-variable-regexp
(if erlang-regexp-modern-p
"\\_<\\([[:upper:]_]\\(?:\\sw\\|\\s_\\)*\\)\\_>"
"\\<\\([[:upper:]_]\\(?:\\sw\\|\\s_\\)*\\)\\>")
"Regexp which should match an Erlang variable.
The regexp must be surrounded with a pair of regexp parentheses."))
(eval-and-compile
(defconst erlang-variable-regexp-matches 1
"Number of regexp parenthesis pairs in `erlang-variable-regexp'.
This is used to determine matches in complex regexps which contains
`erlang-variable-regexp'."))
(eval-and-compile
(defun erlang-regexp-opt (strings &optional paren)
"Like `regexp-opt', except if PAREN is `symbols', then the
resulting regexp is surrounded by \\_< and \\_>."
(if (eq paren 'symbols)
(if erlang-regexp-modern-p
(concat "\\_<" (regexp-opt strings t) "\\_>")
(concat "\\<" (regexp-opt strings t) "\\>"))
(regexp-opt strings paren))))
(eval-and-compile
(defvar erlang-keywords
'("after"
"begin"
"catch"
"case"
"cond"
"end"
"fun"
"if"
"let"
"of"
"query"
"receive"
"try"
"when")
"Erlang reserved keywords"))
(eval-and-compile
(defconst erlang-keywords-regexp (erlang-regexp-opt erlang-keywords 'symbols)))
(eval-and-compile
(defvar erlang-operators
'("and"
"andalso"
"band"
"bnot"
"bor"
"bsl"
"bsr"
"bxor"
"div"
"not"
"or"
"orelse"
"rem"
"xor")
"Erlang operators"))
;; What about these?
;; '+' '-' '*' '/' '>', '>=', '<', '=<', '=:=', '==', '=/=', '/='
(eval-and-compile
(defconst erlang-operators-regexp (erlang-regexp-opt erlang-operators 'symbols)))
(eval-and-compile
(defvar erlang-guards
'("is_atom"
"is_binary"
"is_bitstring"
"is_boolean"
"is_float"
"is_function"
"is_integer"
"is_list"
"is_number"
"is_pid"
"is_port"
"is_record"
"is_reference"
"is_tuple"
"atom"
"binary"
"bitstring"
"boolean"
;;"float" ; Not included to avoid clashes with the bif float/1
"function"
"integer"
"list"
"number"
"pid"
"port"
"record"
"reference"
"tuple")
"Erlang guards"))
(eval-and-compile
(defconst erlang-guards-regexp (erlang-regexp-opt erlang-guards 'symbols)))
(eval-and-compile
(defvar erlang-predefined-types
'("any"
"arity"
"boolean"
"byte"
"char"
"cons"
"deep_string"
"iolist"
"maybe_improper_list"
"module"
"mfa"
"nil"
"neg_integer"
"none"
"non_neg_integer"
"nonempty_list"
"nonempty_improper_list"
"nonempty_maybe_improper_list"
"no_return"
"pos_integer"
"string"
"term"
"timeout")
"Erlang type specs types"))
(eval-and-compile
(defconst erlang-predefined-types-regexp
(erlang-regexp-opt erlang-predefined-types 'symbols)))
(eval-and-compile
(defvar erlang-int-bifs
'("abs"
"adler32"
"adler32_combine"
"alive"
"apply"
"atom_to_binary"
"atom_to_list"
"binary_to_atom"
"binary_to_existing_atom"
"binary_to_list"
"binary_to_term"
"bit_size"
"bitstring_to_list"
"byte_size"
"check_process_code"
"contact_binary"
"crc32"
"crc32_combine"
"date"
"decode_packet"
"delete_module"
"disconnect_node"
"element"
"erase"
"exit"
"float"
"float_to_list"
"garbage_collect"
"get"
"get_keys"
"group_leader"
"halt"
"hd"
"integer_to_list"
"internal_bif"
"iolist_size"
"iolist_to_binary"
"is_alive"
"is_atom"
"is_binary"
"is_bitstring"
"is_boolean"
"is_float"
"is_function"
"is_integer"
"is_list"
"is_number"
"is_pid"
"is_port"
"is_process_alive"
"is_record"
"is_reference"
"is_tuple"
"length"
"link"
"list_to_atom"
"list_to_binary"
"list_to_bitstring"
"list_to_existing_atom"
"list_to_float"
"list_to_integer"
"list_to_pid"
"list_to_tuple"
"load_module"
"make_ref"
"module_loaded"
"monitor_node"
"node"
"node_link"
"node_unlink"
"nodes"
"notalive"
"now"
"open_port"
"pid_to_list"
"port_close"
"port_command"
"port_connect"
"port_control"
"pre_loaded"
"process_flag"
"process_info"
"processes"
"purge_module"
"put"
"register"
"registered"
"round"
"self"
"setelement"
"size"
"spawn"
"spawn_link"
"spawn_monitor"
"spawn_opt"
"split_binary"
"statistics"
"term_to_binary"
"time"
"throw"
"tl"
"trunc"
"tuple_size"
"tuple_to_list"
"unlink"
"unregister"
"whereis")
"Erlang built-in functions (BIFs)"))
(eval-and-compile
(defconst erlang-int-bif-regexp (erlang-regexp-opt erlang-int-bifs 'symbols)))
(eval-and-compile
(defvar erlang-ext-bifs
'("append_element"
"bump_reductions"
"cancel_timer"
"demonitor"
"display"
"fun_info"
"fun_to_list"
"function_exported"
"get_cookie"
"get_stacktrace"
"hash"
"integer_to_list"
"is_builtin"
"list_to_integer"
"loaded"
"localtime"
"localtime_to_universaltime"
"make_tuple"
"max"
"md5"
"md5_final"
"md5_init"
"md5_update"
"memory"
"min"
"monitor"
"monitor_node"
"phash"
"phash2"
"port_call"
"port_info"
"port_to_list"
"ports"
"process_display"
"read_timer"
"ref_to_list"
"resume_process"
"send"
"send_after"
"send_nosuspend"
"set_cookie"
"start_timer"
"suspend_process"
"system_flag"
"system_info"
"system_monitor"
"system_profile"
"trace"
"trace_delivered"
"trace_info"
"trace_pattern"
"universaltime"
"universaltime_to_localtime"
"yield")
"Erlang built-in functions (BIFs) that needs erlang: prefix"))
(eval-and-compile
(defconst erlang-ext-bif-regexp
(erlang-regexp-opt (append erlang-int-bifs erlang-ext-bifs) 'symbols)))
(defvar erlang-defun-prompt-regexp (concat "^" erlang-atom-regexp "\\s *(")
"Regexp which should match beginning of a clause.")
(defvar erlang-file-name-extension-regexp "\\.[eh]rl$"
"*Regexp which should match an Erlang file name.
This regexp is used when an Erlang module name is extracted from the
name of an Erlang source file.
The regexp should only match the section of the file name which should
be excluded from the module name.
To match all files set this variable to \"\\\\(\\\\..*\\\\|\\\\)$\".
The matches all except the extension. This is useful if the Erlang
tags system should interpret tags on the form `module:tag' for
files written in other languages than Erlang.")
(defvar erlang-inferior-shell-split-window t
"*If non-nil, when starting an inferior shell, split windows.
If nil, the inferior shell replaces the window. This is the traditional
behaviour.")
(defconst inferior-erlang-use-cmm (boundp 'minor-mode-overriding-map-alist)
"Non-nil means use `compilation-minor-mode' in Erlang shell.")
(defvar erlang-mode-map
(let ((map (make-sparse-keymap)))
(unless (boundp 'indent-line-function)
(define-key map "\t" 'erlang-indent-command))
(define-key map ";" 'erlang-electric-semicolon)
(define-key map "," 'erlang-electric-comma)
(define-key map "<" 'erlang-electric-lt)
(define-key map ">" 'erlang-electric-gt)
(define-key map "\C-m" 'erlang-electric-newline)
(if (not (boundp 'delete-key-deletes-forward))
(define-key map "\177" 'backward-delete-char-untabify)
(define-key map [(backspace)] 'backward-delete-char-untabify))
;;(unless (boundp 'fill-paragraph-function)
(define-key map "\M-q" 'erlang-fill-paragraph)
(unless (boundp 'beginning-of-defun-function)
(define-key map "\M-\C-a" 'erlang-beginning-of-function)
(define-key map "\M-\C-e" 'erlang-end-of-function)
(define-key map '(meta control h) 'erlang-mark-function)) ; Xemacs
(define-key map "\M-\t" 'erlang-complete-tag)
(define-key map "\C-c\M-\t" 'tempo-complete-tag)
(define-key map "\M-+" 'erlang-find-next-tag)
(define-key map "\C-c\M-a" 'erlang-beginning-of-clause)
(define-key map "\C-c\M-b" 'tempo-backward-mark)
(define-key map "\C-c\M-e" 'erlang-end-of-clause)
(define-key map "\C-c\M-f" 'tempo-forward-mark)
(define-key map "\C-c\M-h" 'erlang-mark-clause)
(define-key map "\C-c\C-c" 'comment-region)
(define-key map "\C-c\C-j" 'erlang-generate-new-clause)
(define-key map "\C-c\C-k" 'erlang-compile)
(define-key map "\C-c\C-l" 'erlang-compile-display)
(define-key map "\C-c\C-s" 'erlang-show-syntactic-information)
(define-key map "\C-c\C-q" 'erlang-indent-function)
(define-key map "\C-c\C-u" 'erlang-uncomment-region)
(define-key map "\C-c\C-y" 'erlang-clone-arguments)
(define-key map "\C-c\C-a" 'erlang-align-arrows)
(define-key map "\C-c\C-z" 'erlang-shell-display)
(unless inferior-erlang-use-cmm
(define-key map "\C-x`" 'erlang-next-error))
map)
"*Keymap used in Erlang mode.")
(defvar erlang-mode-abbrev-table nil
"Abbrev table in use in Erlang-mode buffers.")
(defvar erlang-mode-syntax-table nil
"Syntax table in use in Erlang-mode buffers.")
(defvar erlang-skel-file "erlang-skels"
"The type of erlang-skeletons that should be used, default
uses edoc type, for the old type, standard comments,
set \"erlang-skels-old\" in your .emacs and restart.
Or define your own and set the variable to that file.")
;; Tempo skeleton templates:
(load erlang-skel-file)
;; Font-lock variables
;; The next few variables define different Erlang font-lock patterns.