unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#31289: madx mode for emacs
@ 2018-04-27 11:00 Oscar Blanco
  2018-06-22  0:50 ` Noam Postavsky
                   ` (4 more replies)
  0 siblings, 5 replies; 15+ messages in thread
From: Oscar Blanco @ 2018-04-27 11:00 UTC (permalink / raw)
  To: 31289


[-- Attachment #1.1: Type: text/plain, Size: 292 bytes --]

Dear emacs group,

I attach a script that I would like you to consider for the ELPA
repository.
This script defines the mad-x mode that highlights buffers with the
"Methodical Accelerator Design" syntax, by default loaded if the file name
ends it ".madx".

Best regards,

o

-- 
Oscar BLANCO

[-- Attachment #1.2: Type: text/html, Size: 560 bytes --]

[-- Attachment #2: madx.el --]
[-- Type: text/x-emacs-lisp, Size: 16504 bytes --]

;;; madx.el --- Major mode for editing MAD-X files in Emacs

;; Copyright (C) 2013, 2016 Oscar BLANCO
;;               2017, 2018 Oscar BLANCO, Istituto Nazionale di Fisica Nucleare

;; Author     : orblancog <orblancog@gmail.com>
;; Maintainer : orblancog
;; Created    : 18 Nov 2017
;; Keywords   : languages
;; Homepage   : https://github.com/orblancog/mad-x_syntax
;; Version    : 1.5

;; This file is not part of GNU Emacs

;; Licensed under the EUPL, Version 1.1 or - as soon they will be
;; approved by the European Commission - subsequent versions of the EUPL
;; (the "Licence"). You may not use this work except in compliance with
;; the Licence. You may obtain a copy of the Licence at:
;;
;; https://joinup.ec.europa.eu/software/page/eupl
;;
;; Unless required by applicable law or agreed to in writing, software
;; distributed under the Licence is distributed on an "AS IS" basis,
;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
;; implied.
;;
;; See the Licence for the specific language governing permissions and
;; limitations under the Licence.

;;; Commentary:
;; FEATURES in version 1.4
;; * Highlights commands, parameters and special operators in MAD-X 5
;; * If the file extension is '.madx' then the buffer is automatically highlighted,
;;   but any buffer can be highlighted by doing :
;;       `M+X madx-mode`
;;   where `M` is the **META** character in Emacs (`M` seems to be **ALT** in Linux)
;; * If the limit of 80 characters is desired, they could be highlighted differently
;;   by uncomment the line
;;       ;(require 'whitespace)
;;       ;(setq whitespace-line-column 80) ;; limit line length
;;       ;(setq whitespace-style '(face lines-tail))
;;       ;(add-hook 'madx-mode-hook 'whitespace-mode)
;;   in this (madx.el) file.
;; HOW TO INSTALL IT
;; For EMACS 2.4 and on it should be available in the EMACS elpa repository,
;; otherwise,
;; 1. Copy this file (madx.el) to the highlighting definition folder, e.g.
;;      a)  ~/.emacs.d/lisp/  ---> (Emacs v24.5.X)
;;      b)  ~/.emacs.d/       ---> (Emacs v23.X.X)
;;      c)  ~/                ---> (Emacs v21.X.X)
;;    i.e.
;;      $ cp madx.el ~/.emacs.d/lisp/
;; 2. Edit or create your .emacs file, typically in ~/
;;      adding the following block where the load-path must match point 1.
;;      ;;;; START OF BLOCK TO COPY AND UNCOMMENT
;;      (global-font-lock-mode t);; Enable syntax highlighting
;;      (setq font-lock-maximum-decoration t)
;;      (add-to-list 'load-path "~/.emacs.d");; <--- edit according to 1.
;;      (autoload 'madx-mode "madx" "MADX-mode" t)
;;      (setq auto-mode-alist (append '(("\\.madx$" . madx-mode))
;;        auto-mode-alist))
;;      ;;;; END OF BLOCK TO COPY AND UNCOMMENT
;; 3. You should now restart EMACS in order to reload the environment variables.
;; INFO
;; * For mad instructions, visit
;;   mad.web.cern.ch/mad/
;; * Other syntax highlightings could be found inside the
;;   mad sources.  Check the 'syntax' folder in the madx dir !
;;   Write me to the email address above about any bug including an example.

;;; History:
;; v 1.0 First release at CERN. File is also available in the
;;       MAD-X sources "syntax" folder.
;; v 1.1 Adding comments and changing some verbosed names
;; v 1.2 email update oscar.roberto.blanco.garcia@cern.ch deprecated
;; v 1.2 Adding some variables from MAD-X 5.02.10 manual
;;       Cleaning up faces 8D
;;       when exceeding 80 chars->extra chars in red
;; v 1.3 adding color to numbers and ;
;; v 1.4 Changes to put this file in the emacs elpa repository
;;       Changing email address to orblancog@gmail.com

;;; Code:
(defgroup madx nil
 "Major mode to edit MAD-X files in emacs."
 :group 'languages)

(defvar madx-mode-hook nil
  "Hook for madx-model initialize nil.")

;(add-to-list 'auto-mode-alist '("\\.madx\\'" . madx-mode))

;;;; add  80 characters line
;;;; (global-whitespace-mode +1)
;(require 'whitespace)
;(setq whitespace-line-column 80) ;; limit line length
;(setq whitespace-style '(face lines-tail))
;(add-hook 'madx-mode-hook 'whitespace-mode)

(defconst madx-font-lock-keywords-face-all
  ;; madx-font-lock-keywords-programflow
  (list
   '("\\<\\(ELSE\\(?:IF\\)?\\|IF\\|MACRO\\|WHILE\\)\\>"
   .  font-lock-keyword-face))
  "Highlighting expressions for MAD-X mode (keywords-all).")

(defconst madx-font-lock-builtin-face-all
  ;; madx-font-lock-keywords-tableaccs
  ;; madx-font-lock-keywords-simul
  ;; madx-font-lock-keywords-controlstm
  ;; madx-font-lock-keywords-filehandstm
  ;; madx-font-lock-keywords-tablehandstm
  ;; madx-font-lock-keywords-beamhandstm
  ;; madx-font-lock-keywords-seqediting
  ;; madx-font-lock-keywords-othrcmds
  ;; madx-font-lock-keywords-matchingmet
  ;; madx-font-lock-keywords-orbit_corr
  ;; madx-font-lock-keywords-plot
  ;; madx-font-lock-keywords-stringatt
  (list
  '("\\<\\(A\\(?:PERTURE\\|SSIGN\\)\\|BEAM\\|C\\(?:ALL\\|O\\(?:GUESS\\|NST\\(?:RAINT\\)?\\|P\\(?:TION\\|YFILE\\)\\|RRECT\\)\\|\\(?:REAT\\|SAV\\|YCL\\)E\\)\\|D\\(?:ELETE\\|UMPSEQU\\|YNAP\\)\\|E\\(?:MIT\\|ND\\(?:EDIT\\|MATCH\\|TRACK\\|_MATCH\\)\\|OPTION\\|PRINT\\|SAVE\\|X\\(?:EC\\|\\(?:I\\|TRAC\\)T\\)\\)\\|F\\(?:ILL\\|LATTEN\\)\\|G\\(?:LOBAL\\|WEIGHT\\)\\|HELP\\|I\\(?:BS\\|NSTALL\\)\\|JACOBIAN\\|L\\(?:INE\\|MDIF\\)\\|M\\(?:A\\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)\\|system\\)\\>"
   . font-lock-builtin-face))
  "Highlighting expressions for MAD-X mode (builtin-all).")

(defconst madx-font-lock-type-face-all
  ;; madx-font-lock-keywords-elements
  (list
   '("\\<\\(BEAMBEAM\\|C\\(?:HANGEREF\\|OLLIMATOR\\|RABCAVITY\\)\\|D\\(?:IPEDGE\\|RIFT\\)\\|E\\(?:\\(?:COLLIM\\|LSEPAR\\)ATOR\\)\\|H\\(?:\\(?:KICKE\\|MONITO\\)R\\)\\|INSTRUMENT\\|KICKER\\|M\\(?:A\\(?:RKER\\|TRIX\\)\\|ONITOR\\|ULTIPOLE\\)\\|NLLENS\\|OCTUPOLE\\|PLACEHOLDER\\|QUADRUPOLE\\|R\\(?:BEND\\|COLLIMATOR\\|F\\(?:CAVITY\\|MULTIPOLE\\)\\)\\|S\\(?:BEND\\|EXTUPOLE\\|OLENOID\\|ROTATION\\)\\|T\\(?:KICKER\\|RANSLATION\\)\\|V\\(?:\\(?:KICKE\\|MONITO\\)R\\)\\|YROTATION\\)\\>"
     . font-lock-type-face))
  "Highlighting expressions for MAD-X mode (type-all).")

(defconst madx-font-lock-warning-face-all
  ;; madx-font-lock-keywords-errordef
  (list
   '("\\<\\(E\\(?:ALIGN\\|FCOMP\\|RROR\\)\\|SETERR\\)\\>"
     . font-lock-warning-face))
  "Highlighting expressions for MAD-X mode (warning-all).")

(defconst madx-font-lock-special_operators
  ;; madx-font-lock-special_operators
  (list
   '("\\(;\\|->\\|:=\\)"
  . font-lock-warning-face))
  "Highlighting expressions for MAD-X mode (special-operators).")

(defconst madx-font-lock-constant-face-all
  ;; madx-font-lock-keywords-constants
  (list
   '("\\<\\(ANTIPROTON\\|C\\(?:ENTRE\\|IRCLE\\|LIGHT\\|OLLIM\\)\\|DEGRAD\\|E\\(?:L\\(?:ECTRON\\|LIPSE\\)\\|MASS\\|NTRY\\|RAD\\|XIT\\)?\\|FALSE\\|H\\(?:BAR\\|YBRID\\)\\|ION\\|LHCSCREEN\\|M\\(?:ARGUERITE\\|UMASS\\)\\|N\\(?:EGMUON\\|MASS\\)\\|OCTAGON\\|P\\(?:I\\|MASS\\|OS\\(?:\\(?:ITR\\|MU\\)ON\\)\\|R\\(?:AD\\|OTON\\)\\)\\|QELECT\\|R\\(?:A\\(?:CETRACK\\|DDEG\\)\\|ECT\\(?:\\(?:ANGL\\|ELLIPS\\)E\\)\\)\\|SIMPLE\\|T\\(?:EAPOT\\|RUE\\|WOPI\\)\\)\\>"
  . font-lock-constant-face))
  "Highlighting expressions for MAD-X mode (constant-all).")

(defconst madx-font-lock-special_constants
  ;; madx-font-lock-special_constants
  (list
   '("\\(#[es]\\)"
  . font-lock-constant-face)
  )
  "Highlighting expressions for MAD-X mode (special_constants).")

(defconst madx-font-lock-doc-face-all
  ;; madx-font-lock-keywords-parameters
  (list
   '("\\<\\(A\\(?:DD\\(?:_\\(?:ANGLE\\|PASS\\)\\)?\\|N\\(?:GLE\\|H[XY]\\)\\|P\\(?:ER\\(?:TYPE\\|_\\(?:OFFSET\\|TOL\\)\\)\\|PEND\\)\\|RE[XY]\\|SCALE\\|T\\|UTOPLACEDOWNSTREAM\\)\\|B\\(?:A\\(?:LANCE\\|R[ES]\\)\\|B\\(?:DIR\\|EAT\\|ORBIT\\|SHAPE\\)\\|CURRENT\\|E\\(?:AM\\(?:1TAB\\|2TAB\\|_ENVELOPE\\)\\|TA\\(?:0\\|QFX\\)?\\)\\|ISEC\\|RHO\\|UNCHED\\|[VY]\\)\\|C\\(?:A\\(?:LLS\\|VALL\\)\\|ENT\\(?:ER_MAGNETS\\|RE\\)\\|H\\(?:ARGE\\|ROM\\)\\|L\\(?:ASS\\|EAR\\|\\(?:IS\\|OSED_ORBI\\)T\\)\\|NLL\\|O\\(?:L\\(?:OUR\\|UMN\\)\\|MMAND\\|ND\\|OL\\|R\\(?:RLIM\\|ZERO\\)?\\|UPLE\\)\\|URRENT\\)\\|D\\(?:AMP\\|E\\(?:BUG\\(?:LEVEL\\)?\\|L\\(?:S\\|TA_DEP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(?:ING\\)?\\|IDTH\\)\\|X\\(?:0\\|BEND\\|DISTR\\|MA\\|SIZE\\|_COL\\)\\|Y\\(?:0\\|DISTR\\|MA\\|SIZE\\|_COL\\)\\|Z\\(?:0\\|\\(?:DIST\\|ERO_SUPP\\)R\\)\\|expr\\|lagf\\|r\\(?:ph[12]\\|v[1-4]\\)\\|[HL]\\)\\>"
    . font-lock-doc-face))
  "Highlighting expressions for MAD-X mode (doc-all).")

(defconst madx-font-lock-function-name-face-all
  ;; madx-font-lock-keywords-functions
  (list
   '("\\<\\(A\\(?:BS\\|COS\\|\\(?:SI\\|TA\\)N\\)\\|C\\(?:EIL\\|OSH?\\)\\|E\\(?:RFC?\\|XP\\)\\|FL\\(?:AT56?\\|OOR\\)\\|GAUSS\\|LOG\\(?:10\\)?\\|R\\(?:ANF\\|OUND\\)\\|S\\(?:IN[CH]?\\|QRT\\)\\|T\\(?:ANH?\\|GAUSS\\)\\)\\>"
     . font-lock-function-name-face))
  "Highlighting expressions for MAD-X mode (name-all)." )

(defconst madx-font-lock-variable-name-face-all
  ;; madx-font-lock-keywords-variables_madx
  (list
   '("\\<\\(A\\(?:LF\\(?:A[1-3][1-3]P?\\|[AXY]\\)\\|PER_[1-4]\\|RAD\\)\\|BET\\(?:A[1-3][1-3]P?\\|[XY]MAX\\|[XY]\\)\\|CIRC\\|D\\(?:D\\(?:P[XY]\\|Q[12]\\|[XY]\\)\\|ELTAP\\|\IS\\(?:P\\(?:[1-4]P[1-3]\\|[1-4]\\)\\|TANCE\\)\\|MU[XY]\\|P[XY]\\|Q[12]\\|TBYDS\\|X\\(?:MAX\\|RMS\\)\\|Y\\(?:MAX\\|RMS\\)\\|[XY]\\)\\|E\\(?:IGN[1-6][1-6]\\|NERGY\\)\\\|FREQ0\\|GAM\\(?:A\\(?:[1-3][1-3]P?\\|[XY]\\)\\|MA\\(?:[1-3][1-3]\\|TR\\)\\)\\|K\\(?:1L\\|2L\\|3L\\|4L\\|5L\\|6L\\|ICK[1-6]\\|[1-6]\\)\\|L\\(?:ENGTH\\|OG\\(?:DIST\\\|TURNS\\)\\|YAPUNOV\\)\\|MU[123XY]\\|N\\(?:1\\(?:MIN\\|[XY]_M\\)?\\|AME\\)\\|O\\(?:N_\\(?:AP\\|ELEM\\)\\|RBIT5\\)\\|P\\(?:DAMP\\|HI[TXY]?\\|SI\\|[TXY\]N\\|[TXY]\\)\\|Q[12S]\\|R\\(?:[1-6][1-6]\\|E\\(?:[1-6][1-6]\\)?\\|M[1-6][1-6]\\|TOL\\)\\|SYNCH_[1-5]\\|T\\(?:[1-6][1-6][1-6]\\|HETA\\|M[1-6][1-6][1-6]\\|N\\)\\|U0\\|W[TXY]\\|X\\(?:COMAX\\|N\\|RMS\\\|TOL\\)\\|Y\\(?:CO\\(?:MAX\\|RMS\\)\\|N\\|TOL\\)\\|k\\(?:[0-4]l\\)\\|mvar[1-4]\\|[RSTXYZ]\\)\\>"
     . font-lock-variable-name-face))
  "Highlighting expressions for MAD-X mode (variable-name-all).")

(defconst madx-font-lock-intfp-name-face-all
  ;; madx- fonts for integers and floating point numbers
  (list
   '("\\<\\(\\([0-9]+\\.?[0-9]*\\|\\.[0-9]+\\)\\([eE][+-]?\\([0-9]+\\.?[0-9]*\\|[0-9]*\\.[0-9]+\\)\\)?\\)\\>"
     . font-lock-keyword-face))
  "Highlighting expresssions for MAD-X mode (integers and floats).")

(defconst madx-font-lock-keywords-4
  (append
   madx-font-lock-special_constants
   madx-font-lock-special_operators
   madx-font-lock-keywords-face-all
   madx-font-lock-constant-face-all
   madx-font-lock-function-name-face-all
   madx-font-lock-type-face-all
   madx-font-lock-variable-name-face-all
   madx-font-lock-builtin-face-all
   madx-font-lock-warning-face-all
   madx-font-lock-doc-face-all
   madx-font-lock-intfp-name-face-all)
 "Balls-out highlighting in MAD-X mode.")

(defvar madx-font-lock-keywords madx-font-lock-keywords-4
  "Default highlighting expressions for MAD-X mode.")

(defvar madx-mode-syntax-table
  (let ((madx-mode-syntax-table (make-syntax-table)))
	
  ;; This is added so entity names with underscores and dots can be more easily parsed
  (modify-syntax-entry ?_ "w" madx-mode-syntax-table)
  (modify-syntax-entry ?. "w" madx-mode-syntax-table)
	
  ;;  Comment styles are similar to C++
  (modify-syntax-entry ?/ ". 124 b" madx-mode-syntax-table)
  (modify-syntax-entry ?* ". 23" madx-mode-syntax-table)
  (modify-syntax-entry ?\n "> b" madx-mode-syntax-table)
  (modify-syntax-entry ?! "< b" madx-mode-syntax-table)
  (modify-syntax-entry ?' "|" madx-mode-syntax-table)
     madx-mode-syntax-table)
  "Syntax table for `madx-mode'.")

;;;###autoload
(defun madx-mode ()
  "Major mode for editing MAD-X script files."
  (interactive)
  (kill-all-local-variables)
  (setq mode-name "MAD-X")
  (setq major-mode 'madx-mode)
  ;;  (use-local-map madx-mode-map)
  (set-syntax-table madx-mode-syntax-table)
  (make-local-variable 'font-lock-defaults)
  (setq font-lock-defaults '(madx-font-lock-keywords nil t))
  ;; Setting up Imenu
  (setq imenu-generic-expression nil)
  (setq imenu-prev-index-position-function nil)
  (setq imenu-extract-index-name-function nil)
  ;;  (imenu-create-index-function)
  ;; Set up search
  (add-hook 'madx-mode-hook
     (lambda ()  (setq case-fold-search t)))
  (run-hooks 'madx-mode-hook))
(provide 'madx-mode)
;;; madx.el ends here

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

end of thread, other threads:[~2020-01-15 20:26 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-27 11:00 bug#31289: madx mode for emacs Oscar Blanco
2018-06-22  0:50 ` Noam Postavsky
2018-10-05  6:52   ` Oscar Blanco
2018-10-24 22:30     ` Noam Postavsky
2018-10-25 22:56 ` Noam Postavsky
2018-10-25 23:18   ` Noam Postavsky
2018-10-26  6:42     ` Eli Zaretskii
2018-10-27  3:27       ` Richard Stallman
2018-10-26 10:41 ` Noam Postavsky
2018-10-26 10:53   ` Noam Postavsky
2018-10-27 10:53 ` Noam Postavsky
2019-09-28 18:13 ` Stefan Kangas
2019-09-28 18:46   ` Noam Postavsky
2019-09-28 18:55     ` Stefan Kangas
2020-01-15 20:26       ` Stefan Kangas

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).