Use regexp-opt instead of manual regexes
This helps maintainability tremendously. Thanks wasamasa for the snippet
This commit is contained in:
parent
8a2f8bf260
commit
a897492b99
1 changed files with 26 additions and 29 deletions
|
@ -100,35 +100,32 @@ Otherwise it builds `prettify-code-symbols-alist' according to
|
||||||
|
|
||||||
;;; Automatic font-specific ligatures
|
;;; Automatic font-specific ligatures
|
||||||
(defvar +prog-ligatures-alist
|
(defvar +prog-ligatures-alist
|
||||||
'((?! . "!\\(?:\\(==\\|[!=]\\)[!=]?\\)")
|
`((?! . ,(regexp-opt '("!!" "!=" "!==")))
|
||||||
(?# . "#\\(?:\\(###?\\|_(\\|[(:=?[_{]\\)[#(:=?[_{]?\\)")
|
(?# . ,(regexp-opt '("##" "###" "####" "#(" "#:" "#=" "#?" "#[" "#_" "#_(" "#{")))
|
||||||
(?$ . "$\\(?:\\(>\\)>?\\)")
|
(?$ . ,(regexp-opt '("$>" "$>>")))
|
||||||
(?% . "%\\(?:\\(%\\)%?\\)")
|
(?% . ,(regexp-opt '("%%" "%%%")))
|
||||||
(?& . "&\\(?:\\(&\\)&?\\)")
|
(?& . ,(regexp-opt '("&&" "&&&")))
|
||||||
(?* . "*\\(?:\\(\\*\\*\\|[*>]\\)[*>]?\\)")
|
(?* . ,(regexp-opt '("*" "**" "***" "**/" "*/" "*>")))
|
||||||
;; (?* . "*\\(?:\\(\\*\\*\\|[*/>]\\).?\\)")
|
(?+ . ,(regexp-opt '("+" "++" "+++" "+>")))
|
||||||
(?+ . "+\\(?:\\([>]\\)>?\\)")
|
(?- . ,(regexp-opt '("--" "---" "-->" "-<" "-<<" "->" "->>" "-}" "-~")))
|
||||||
;; (?+ . "+\\(?:\\(\\+\\+\\|[+>]\\).?\\)")
|
(?. . ,(regexp-opt '(".-" ".." "..." "..<" ".=")))
|
||||||
(?- . "-\\(?:\\(-[->]\\|<<\\|>>\\|[-<>|~]\\)[-<>|~]?\\)")
|
(?/ . ,(regexp-opt '("/*" "/**" "//" "///" "/=" "/==" "/>")))
|
||||||
;; (?. . "\\.\\(?:\\(\\.[.<]\\|[-.=]\\)[-.<=]?\\)")
|
(?: . ,(regexp-opt '(":" "::" ":::" ":=" ":<" ":=" ":>")))
|
||||||
(?. . "\\.\\(?:\\(\\.<\\|[-=]\\)[-<=]?\\)")
|
(?0 . "0\\(?:\\(x[a-fA-F0-9]\\).?\\)") ; Tries to match the x in 0xDEADBEEF
|
||||||
(?/ . "/\\(?:\\(//\\|==\\|[=>]\\)[/=>]?\\)")
|
;; (?x . ,(regexp-opt '("x"))) ; Also tries to match the x in 0xDEADBEEF
|
||||||
;; (?/ . "/\\(?:\\(//\\|==\\|[*/=>]\\).?\\)")
|
(?\; . ,(regexp-opt '(";;")))
|
||||||
(?0 . "0\\(?:\\(x[a-fA-F0-9]\\).?\\)")
|
(?< . ,(regexp-opt '("<!--" "<$" "<$>" "<*" "<*>" "<+" "<+>" "<-" "<--" "<->" "</" "</>" "<<" "<<-" "<<<" "<<=" "<=" "<=" "<=<" "<==" "<=>" "<>" "<|" "<|>" "<~" "<~~")))
|
||||||
(?: . ":\\(?:\\(::\\|[:<=>]\\)[:<=>]?\\)")
|
(?= . ,(regexp-opt '("=/=" "=:=" "=<<" "==" "===" "==>" "=>" "=>>")))
|
||||||
(59 . ";\\(?:\\(;\\);?\\)") ;; 59 is ;
|
(?> . ,(regexp-opt '(">-" ">->" ">:" ">=" ">=>" ">>" ">>-" ">>=" ">>>")))
|
||||||
(?< . "<\\(?:\\(!--\\|\\$>\\|\\*>\\|\\+>\\|-[-<>|]\\|/>\\|<[-<=]\\|=[<>|]\\|==>?\\||>\\||||?\\|~[>~]\\|[$*+/:<=>|~-]\\)[$*+/:<=>|~-]?\\)")
|
(?? . ,(regexp-opt '("??" "?." "?:" "?=")))
|
||||||
(?= . "=\\(?:\\(!=\\|/=\\|:=\\|<<\\|=[=>]\\|>>\\|[=>]\\)[=<>]?\\)")
|
(?\[ . ,(regexp-opt '("[]" "[|]" "[|")))
|
||||||
(?> . ">\\(?:\\(->\\|=>\\|>[-=>]\\|[-:=>]\\)[-:=>]?\\)")
|
(?\\ . ,(regexp-opt '("\\\\" "\\\\\\" "\\\\n")))
|
||||||
(?? . "?\\(?:\\([.:=?]\\)[.:=?]?\\)")
|
(?^ . ,(regexp-opt '("^=" "^==")))
|
||||||
(91 . "\\[\\(?:\\(|\\)[]|]?\\)") ;; 91 is [
|
(?w . ,(regexp-opt '("www" "wwww")))
|
||||||
;; (?\ . "\\\\\\(?:\\([\\n]\\)[\\]?\\)")
|
(?{ . ,(regexp-opt '("{-" "{|" "{||" "{|}" "{||}")))
|
||||||
(?^ . "^\\(?:\\(=\\)=?\\)")
|
(?| . ,(regexp-opt '("|=" "|>" "||" "||=" "|->" "|=>" "|]" "|}")))
|
||||||
(?_ . "_\\(?:\\(|_\\|[_]\\)_?\\)")
|
(?_ . ,(regexp-opt '("_|_" "__")))
|
||||||
(?w . "w\\(?:\\(ww\\)w?\\)")
|
(?~ . ,(regexp-opt '("~-" "~=" "~>" "~@" "~~" "~~>"))))
|
||||||
(?{ . "{\\(?:\\(|\\)[|}]?\\)")
|
|
||||||
(?| . "|\\(?:\\(->\\|=>\\||[-=>]\\||||*>\\|[]=>|}-]\\).?\\)")
|
|
||||||
(?~ . "~\\(?:\\(~>\\|[-=>@~]\\)[-=>@~]?\\)"))
|
|
||||||
"An alist containing all the ligatures used when in a `+prog-ligatures-modes' mode.
|
"An alist containing all the ligatures used when in a `+prog-ligatures-modes' mode.
|
||||||
|
|
||||||
The car is the character ASCII number, cdr is a regex which will call `font-shape-gstring'
|
The car is the character ASCII number, cdr is a regex which will call `font-shape-gstring'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue