emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/dash e7bc8fe 250/426: Make dash-specific font lock opti


From: Phillip Lord
Subject: [elpa] externals/dash e7bc8fe 250/426: Make dash-specific font lock optional
Date: Tue, 04 Aug 2015 19:38:04 +0000

branch: externals/dash
commit e7bc8feb6aea44f6585943d411acebd8b0dd1249
Author: Magnar Sveen <address@hidden>
Commit: Magnar Sveen <address@hidden>

    Make dash-specific font lock optional
    
    Closes #52
---
 README.md          |    9 ++-
 dash.el            |  326 ++++++++++++++++++++++++++--------------------------
 readme-template.md |    7 +
 3 files changed, 179 insertions(+), 163 deletions(-)

diff --git a/README.md b/README.md
index e16cd06..0ddcdfa 100644
--- a/README.md
+++ b/README.md
@@ -44,6 +44,13 @@ To get function combinators:
 
     ;; Package-Requires: ((dash "1.8.0") (dash-functional "1.0.0") (emacs 
"24"))
 
+## Syntax highlighting of dash functions
+
+Font lock of dash functions in emacs lisp buffers is now optional.
+Include this in your emacs settings to get syntax highlighting:
+
+    (eval-after-load "dash" '(dash-enable-font-lock))
+
 ## Functions
 
 
@@ -1038,7 +1045,7 @@ but is twice as fast as it only traverse the structure 
once.
 
 ```cl
 (-tree-mapreduce-from 'identity '* 1 '(1 (2 (3 4) (5 6)) (7 (8 9)))) ;; => 
362880
-(--tree-mapreduce-from (+ it it) (cons it acc) nil '(1 (2 (4 9) (2 1)) (7 (4 
3)))) ;; => (2 (4 (8 18) (4 2)) (14 (8 6)))
+(--tree-mapreduce-from (+ it it) (cons it acc) nil '(1 (2 (4 9) (2 1)) (7 (4 
3)))) ;; => '(2 (4 (8 18) (4 2)) (14 (8 6)))
 (concat "{" (--tree-mapreduce-from (cond ((-cons-pair? it) (concat 
(symbol-name (car it)) " -> " (symbol-name (cdr it)))) (t (concat (symbol-name 
it) " : {"))) (concat it (unless (or (equal acc "}") (equal (substring it (1- 
(length it))) "{")) ", ") acc) "}" '((elips-mode (foo (bar . booze)) (baz . 
qux)) (c-mode (foo . bla) (bum . bam))))) ;; => "{elips-mode : {foo : {bar -> 
booze}, baz -> qux}, c-mode : {foo -> bla, bum -> bam}}"
 ```
 
diff --git a/dash.el b/dash.el
index 2938398..afc8752 100644
--- a/dash.el
+++ b/dash.el
@@ -843,7 +843,7 @@ otherwise do ELSE. VAR-VAL should be a (VAR VAL) pair."
     (if (= (length vars-vals) 1)
         `(-if-let ,first-pair ,then ,@else)
       `(-if-let ,first-pair
-           (-if-let* ,rest ,then ,@else)
+         (-if-let* ,rest ,then ,@else)
          ,@else))))
 
 (defmacro --if-let (val then &rest else)
@@ -1065,7 +1065,7 @@ then on this result and second element from the list etc.
 
 The initial value is ignored on cons pairs as they always contain
 two elements."
-   (cond
+  (cond
    ((not tree) nil)
    ((-cons-pair? tree) tree)
    ((listp tree)
@@ -1084,7 +1084,7 @@ FN is first applied to first element of the list and 
second
 element, then on this result and third element from the list etc.
 
 See `-reduce-r' for how exactly are lists of zero or one element handled."
-   (cond
+  (cond
    ((not tree) nil)
    ((-cons-pair? tree) tree)
    ((listp tree)
@@ -1102,165 +1102,167 @@ replaced with new ones.  This is useful when you need 
to clone a
 structure such as plist or alist."
   (-tree-map 'identity list))
 
-(eval-after-load "lisp-mode"
-  '(progn
-     (let ((new-keywords '(
-                           "--each"
-                           "-each"
-                           "--each-while"
-                           "-each-while"
-                           "--dotimes"
-                           "-dotimes"
-                           "-map"
-                           "--map"
-                           "--reduce-from"
-                           "-reduce-from"
-                           "--reduce"
-                           "-reduce"
-                           "--reduce-r-from"
-                           "-reduce-r-from"
-                           "--reduce-r"
-                           "-reduce-r"
-                           "--filter"
-                           "-filter"
-                           "-select"
-                           "--select"
-                           "--remove"
-                           "-remove"
-                           "-reject"
-                           "--reject"
-                           "--keep"
-                           "-keep"
-                           "-flatten"
-                           "-concat"
-                           "--mapcat"
-                           "-mapcat"
-                           "--first"
-                           "-first"
-                           "--any?"
-                           "-any?"
-                           "-some?"
-                           "--some?"
-                           "-any-p"
-                           "--any-p"
-                           "-some-p"
-                           "--some-p"
-                           "--all?"
-                           "-all?"
-                           "-every?"
-                           "--every?"
-                           "-all-p"
-                           "--all-p"
-                           "-every-p"
-                           "--every-p"
-                           "--none?"
-                           "-none?"
-                           "-none-p"
-                           "--none-p"
-                           "-only-some?"
-                           "--only-some?"
-                           "-only-some-p"
-                           "--only-some-p"
-                           "-take"
-                           "-drop"
-                           "--take-while"
-                           "-take-while"
-                           "--drop-while"
-                           "-drop-while"
-                           "-split-at"
-                           "-rotate"
-                           "-insert-at"
-                           "--split-with"
-                           "-split-with"
-                           "-partition"
-                           "-partition-in-steps"
-                           "-partition-all"
-                           "-partition-all-in-steps"
-                           "-interpose"
-                           "-interleave"
-                           "--zip-with"
-                           "-zip-with"
-                           "-zip"
-                           "--map-indexed"
-                           "-map-indexed"
-                           "--map-when"
-                           "-map-when"
-                           "--replace-where"
-                           "-replace-where"
-                           "-partial"
-                           "-rpartial"
-                           "-juxt"
-                           "-applify"
-                           "-on"
-                           "-flip"
-                           "-const"
-                           "-cut"
-                           "-orfn"
-                           "-andfn"
-                           "-elem-index"
-                           "-elem-indices"
-                           "-find-indices"
-                           "--find-indices"
-                           "-find-index"
-                           "--find-index"
-                           "-select-by-indices"
-                           "-grade-up"
-                           "-grade-down"
-                           "->"
-                           "->>"
-                           "-->"
-                           "-when-let"
-                           "-when-let*"
-                           "--when-let"
-                           "-if-let"
-                           "-if-let*"
-                           "--if-let"
-                           "-union"
-                           "-distinct"
-                           "-intersection"
-                           "-difference"
-                           "-contains?"
-                           "-contains-p"
-                           "-repeat"
-                           "-cons*"
-                           "-sum"
-                           "-product"
-                           "-min"
-                           "-min-by"
-                           "--min-by"
-                           "-max"
-                           "-max-by"
-                           "--max-by"
-                           "-cons-to-list"
-                           "-value-to-list"
-                           "-tree-mapreduce-from"
-                           "--tree-mapreduce-from"
-                           "-tree-mapreduce"
-                           "--tree-mapreduce"
-                           "-tree-map"
-                           "--tree-map"
-                           "-tree-reduce-from"
-                           "--tree-reduce-from"
-                           "-tree-reduce"
-                           "--tree-reduce"
-                           "-clone"
-                           ))
-           (special-variables '(
-                                "it"
-                                "it-index"
-                                "acc"
-                                "other"
-                                )))
-       (font-lock-add-keywords 'emacs-lisp-mode `((,(concat "\\<" (regexp-opt 
special-variables 'paren) "\\>")
-                                                   1 
font-lock-variable-name-face)) 'append)
-       (font-lock-add-keywords 'emacs-lisp-mode `((,(concat "(\\s-*" 
(regexp-opt new-keywords 'paren) "\\>")
-                                                   1 font-lock-keyword-face)) 
'append))
-     (--each (buffer-list)
-       (with-current-buffer it
-         (when (and (eq major-mode 'emacs-lisp-mode)
-                    (boundp 'font-lock-mode)
-                    font-lock-mode)
-           (font-lock-refresh-defaults))))))
+(defun dash-enable-font-lock ()
+  "Add syntax highlighting to dash functions, macros and magic values."
+  (eval-after-load "lisp-mode"
+    '(progn
+       (let ((new-keywords '(
+                             "--each"
+                             "-each"
+                             "--each-while"
+                             "-each-while"
+                             "--dotimes"
+                             "-dotimes"
+                             "-map"
+                             "--map"
+                             "--reduce-from"
+                             "-reduce-from"
+                             "--reduce"
+                             "-reduce"
+                             "--reduce-r-from"
+                             "-reduce-r-from"
+                             "--reduce-r"
+                             "-reduce-r"
+                             "--filter"
+                             "-filter"
+                             "-select"
+                             "--select"
+                             "--remove"
+                             "-remove"
+                             "-reject"
+                             "--reject"
+                             "--keep"
+                             "-keep"
+                             "-flatten"
+                             "-concat"
+                             "--mapcat"
+                             "-mapcat"
+                             "--first"
+                             "-first"
+                             "--any?"
+                             "-any?"
+                             "-some?"
+                             "--some?"
+                             "-any-p"
+                             "--any-p"
+                             "-some-p"
+                             "--some-p"
+                             "--all?"
+                             "-all?"
+                             "-every?"
+                             "--every?"
+                             "-all-p"
+                             "--all-p"
+                             "-every-p"
+                             "--every-p"
+                             "--none?"
+                             "-none?"
+                             "-none-p"
+                             "--none-p"
+                             "-only-some?"
+                             "--only-some?"
+                             "-only-some-p"
+                             "--only-some-p"
+                             "-take"
+                             "-drop"
+                             "--take-while"
+                             "-take-while"
+                             "--drop-while"
+                             "-drop-while"
+                             "-split-at"
+                             "-rotate"
+                             "-insert-at"
+                             "--split-with"
+                             "-split-with"
+                             "-partition"
+                             "-partition-in-steps"
+                             "-partition-all"
+                             "-partition-all-in-steps"
+                             "-interpose"
+                             "-interleave"
+                             "--zip-with"
+                             "-zip-with"
+                             "-zip"
+                             "--map-indexed"
+                             "-map-indexed"
+                             "--map-when"
+                             "-map-when"
+                             "--replace-where"
+                             "-replace-where"
+                             "-partial"
+                             "-rpartial"
+                             "-juxt"
+                             "-applify"
+                             "-on"
+                             "-flip"
+                             "-const"
+                             "-cut"
+                             "-orfn"
+                             "-andfn"
+                             "-elem-index"
+                             "-elem-indices"
+                             "-find-indices"
+                             "--find-indices"
+                             "-find-index"
+                             "--find-index"
+                             "-select-by-indices"
+                             "-grade-up"
+                             "-grade-down"
+                             "->"
+                             "->>"
+                             "-->"
+                             "-when-let"
+                             "-when-let*"
+                             "--when-let"
+                             "-if-let"
+                             "-if-let*"
+                             "--if-let"
+                             "-union"
+                             "-distinct"
+                             "-intersection"
+                             "-difference"
+                             "-contains?"
+                             "-contains-p"
+                             "-repeat"
+                             "-cons*"
+                             "-sum"
+                             "-product"
+                             "-min"
+                             "-min-by"
+                             "--min-by"
+                             "-max"
+                             "-max-by"
+                             "--max-by"
+                             "-cons-to-list"
+                             "-value-to-list"
+                             "-tree-mapreduce-from"
+                             "--tree-mapreduce-from"
+                             "-tree-mapreduce"
+                             "--tree-mapreduce"
+                             "-tree-map"
+                             "--tree-map"
+                             "-tree-reduce-from"
+                             "--tree-reduce-from"
+                             "-tree-reduce"
+                             "--tree-reduce"
+                             "-clone"
+                             ))
+             (special-variables '(
+                                  "it"
+                                  "it-index"
+                                  "acc"
+                                  "other"
+                                  )))
+         (font-lock-add-keywords 'emacs-lisp-mode `((,(concat "\\<" 
(regexp-opt special-variables 'paren) "\\>")
+                                                     1 
font-lock-variable-name-face)) 'append)
+         (font-lock-add-keywords 'emacs-lisp-mode `((,(concat "(\\s-*" 
(regexp-opt new-keywords 'paren) "\\>")
+                                                     1 
font-lock-keyword-face)) 'append))
+       (--each (buffer-list)
+         (with-current-buffer it
+           (when (and (eq major-mode 'emacs-lisp-mode)
+                      (boundp 'font-lock-mode)
+                      font-lock-mode)
+             (font-lock-refresh-defaults)))))))
 
 (provide 'dash)
 ;;; dash.el ends here
diff --git a/readme-template.md b/readme-template.md
index e483bb0..a8be55a 100644
--- a/readme-template.md
+++ b/readme-template.md
@@ -44,6 +44,13 @@ To get function combinators:
 
     ;; Package-Requires: ((dash "1.8.0") (dash-functional "1.0.0") (emacs 
"24"))
 
+## Syntax highlighting of dash functions
+
+Font lock of dash functions in emacs lisp buffers is now optional.
+Include this in your emacs settings to get syntax highlighting:
+
+    (eval-after-load "dash" '(dash-enable-font-lock))
+
 ## Functions
 
 [[ function-list ]]



reply via email to

[Prev in Thread] Current Thread [Next in Thread]