Optimize +prog-ligatures-alist

But preserve regexp-opt forms for users who want to contribute.
This commit is contained in:
Henrik Lissner 2020-05-06 13:53:54 -04:00
parent 8f4684a69b
commit bc0477c3ba
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -51,34 +51,34 @@ besides what is listed.")
;;; Automatic font-specific ligatures ;;; Automatic font-specific ligatures
(defvar +prog-ligatures-alist (defvar +prog-ligatures-alist
(eval-when-compile '((?! . "\\(?:!\\(?:==\\|[!=]\\)\\)") ; (regexp-opt '("!!" "!=" "!=="))
`((?! . ,(regexp-opt '("!!" "!=" "!=="))) (?# . "\\(?:#\\(?:###?\\|_(\\|[#(:=?[_{]\\)\\)") ; (regexp-opt '("##" "###" "####" "#(" "#:" "#=" "#?" "#[" "#_" "#_(" "#{"))
(?# . ,(regexp-opt '("##" "###" "####" "#(" "#:" "#=" "#?" "#[" "#_" "#_(" "#{"))) (?$ . "\\(?:\\$>>?\\)") ; (regexp-opt '("$>" "$>>"))
(?$ . ,(regexp-opt '("$>" "$>>"))) (?% . "\\(?:%%%?\\)") ; (regexp-opt '("%%" "%%%"))
(?% . ,(regexp-opt '("%%" "%%%"))) (?& . "\\(?:&&&?\\)") ; (regexp-opt '("&&" "&&&"))
(?& . ,(regexp-opt '("&&" "&&&"))) (?* . "\\(?:\\*\\(?:\\*[*/]\\|[)*/>]\\)?\\)") ; (regexp-opt '("*" "**" "***" "**/" "*/" "*>" "*)"))
(?* . ,(regexp-opt '("*" "**" "***" "**/" "*/" "*>" "*)"))) (?+ . "\\(?:\\+\\(?:\\+\\+\\|[+:>]\\)?\\)") ; (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 (?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 ;; (?x . "x") ; Also tries to match the x in 0xDEADBEEF
(?\; . ,(regexp-opt '(";;"))) ;; (regexp-opt '("<!--" "<$" "<$>" "<*" "<*>" "<**>" "<+" "<+>" "<-" "<--" "<---" "<->" "<-->" "<--->" "</" "</>" "<<" "<<-" "<<<" "<<=" "<=" "<=<" "<==" "<=>" "<===>" "<>" "<|" "<|>" "<~" "<~~" "<." "<.>" "<..>"))
(?< . ,(regexp-opt '("<!--" "<$" "<$>" "<*" "<*>" "<**>" "<+" "<+>" "<-" "<--" "<---" "<->" "<-->" "<--->" "</" "</>" "<<" "<<-" "<<<" "<<=" "<=" "<=<" "<==" "<=>" "<===>" "<>" "<|" "<|>" "<~" "<~~" "<." "<.>" "<..>"))) (?< . "\\(?:<\\(?:!--\\|\\$>\\|\\*\\(?:\\*?>\\)\\|\\+>\\|-\\(?:-\\(?:->\\|[>-]\\)\\|[>-]\\)\\|\\.\\(?:\\.?>\\)\\|/>\\|<[<=-]\\|=\\(?:==>\\|[<=>]\\)\\||>\\|~~\\|[$*+./<=>|~-]\\)\\)")
(?= . ,(regexp-opt '("=/=" "=:=" "=<<" "==" "===" "==>" "=>" "=>>"))) (?= . "\\(?:=\\(?:/=\\|:=\\|<<\\|=[=>]\\|>>\\|[=>]\\)\\)") ; (regexp-opt '("=/=" "=:=" "=<<" "==" "===" "==>" "=>" "=>>"))
(?> . ,(regexp-opt '(">-" ">->" ">:" ">=" ">=>" ">>" ">>-" ">>=" ">>>"))) (?> . "\\(?:>\\(?:->\\|=>\\|>[=>-]\\|[:=>-]\\)\\)") ; (regexp-opt '(">-" ">->" ">:" ">=" ">=>" ">>" ">>-" ">>=" ">>>"))
(?? . ,(regexp-opt '("??" "?." "?:" "?="))) (?? . "\\(?:\\?[.:=?]\\)") ; (regexp-opt '("??" "?." "?:" "?="))
(?\[ . ,(regexp-opt '("[]" "[|]" "[|"))) (?\[ . "\\(?:\\[\\(?:|]\\|[]|]\\)\\)") ; (regexp-opt '("[]" "[|]" "[|"))
(?\\ . ,(regexp-opt '("\\\\" "\\\\\\" "\\\\n"))) (?\\ . "\\(?:\\\\\\\\[\\n]?\\)") ; (regexp-opt '("\\\\" "\\\\\\" "\\\\n"))
(?^ . ,(regexp-opt '("^=" "^=="))) (?^ . "\\(?:\\^==?\\)") ; (regexp-opt '("^=" "^=="))
(?w . ,(regexp-opt '("www" "wwww"))) (?w . "\\(?:wwww?\\)") ; (regexp-opt '("www" "wwww"))
(?{ . ,(regexp-opt '("{-" "{|" "{||" "{|}" "{||}"))) (?{ . "\\(?:{\\(?:|\\(?:|}\\|[|}]\\)\\|[|-]\\)\\)") ; (regexp-opt '("{-" "{|" "{||" "{|}" "{||}"))
(?| . ,(regexp-opt '("|=" "|>" "||" "||=" "|->" "|=>" "|]" "|}" "|-"))) (?| . "\\(?:|\\(?:->\\|=>\\||=\\|[]=>|}-]\\)\\)") ; (regexp-opt '("|=" "|>" "||" "||=" "|->" "|=>" "|]" "|}" "|-"))
(?_ . ,(regexp-opt '("_|_" "__"))) (?_ . "\\(?:_\\(?:|?_\\)\\)") ; (regexp-opt '("_|_" "__"))
(?\( . ,(regexp-opt '("(*"))) (?\( . "\\(?:(\\*\\)") ; (regexp-opt '("(*"))
(?~ . ,(regexp-opt '("~-" "~=" "~>" "~@" "~~" "~~>"))))) (?~ . "\\(?:~\\(?:~>\\|[=>@~-]\\)\\)")) ; (regexp-opt '("~-" "~=" "~>" "~@" "~~" "~~>"))
"An alist of all ligatures used by `+prog-ligatures-modes'. "An alist of all ligatures used by `+prog-ligatures-modes'.
The car is the character ASCII number, cdr is a regex which will call The car is the character ASCII number, cdr is a regex which will call