emacs-diffs
[Top][All Lists]
Advanced

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

master d398eca: * lisp/svg.el: Fix typo in sample code; add minor optimi


From: Stefan Monnier
Subject: master d398eca: * lisp/svg.el: Fix typo in sample code; add minor optimization
Date: Sat, 24 Apr 2021 14:07:17 -0400 (EDT)

branch: master
commit d398eca44e119d60f21494a34050e6ca5bc9df8b
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    * lisp/svg.el: Fix typo in sample code; add minor optimization
    
    (svg--elliptical-arc-command, svg--moveto-command)
    (svg--lineto-command): Use `mapcan`.
---
 lisp/svg.el | 48 ++++++++++++++++++++++--------------------------
 1 file changed, 22 insertions(+), 26 deletions(-)

diff --git a/lisp/svg.el b/lisp/svg.el
index 717c847..05accf4 100644
--- a/lisp/svg.el
+++ b/lisp/svg.el
@@ -41,7 +41,7 @@
 ;; into the buffer:
 ;;
 ;;     (setq svg (svg-create 800 800 :stroke "orange" :stroke-width 5))
-;;     (svg-gradient svg "gradient" 'linear '(0 . "red") '(100 . "blue"))
+;;     (svg-gradient svg "gradient" 'linear '((0 . "red") (100 . "blue")))
 ;;     (save-excursion (goto-char (point-max)) (svg-insert-image svg))
 
 ;; Then add various elements to the structure:
@@ -81,7 +81,7 @@ STOPS is a list of percentage/color pairs."
   (svg--def
    svg
    (apply
-    'dom-node
+    #'dom-node
     (if (eq type 'linear)
        'linearGradient
       'radialGradient)
@@ -358,8 +358,7 @@ This is in contrast to merely setting it to 0."
                     (plist-get command-args :default-relative))))
     (intern (if relative (downcase char) (upcase char)))))
 
-(defun svg--elliptical-arc-coordinates
-    (rx ry x y &rest args)
+(defun svg--elliptical-arc-coordinates (rx ry x y &rest args)
   (list
    rx ry
    (or (plist-get args :x-axis-rotation) 0)
@@ -370,21 +369,19 @@ This is in contrast to merely setting it to 0."
 (defun svg--elliptical-arc-command (coordinates-list &rest args)
   (cons
    (svg--path-command-symbol 'a args)
-   (apply 'append
-          (mapcar
-           (lambda (coordinates)
-             (apply 'svg--elliptical-arc-coordinates
-                    coordinates))
-           coordinates-list))))
+   (mapcan
+    (lambda (coordinates)
+      (apply #'svg--elliptical-arc-coordinates
+             coordinates))
+    coordinates-list)))
 
 (defun svg--moveto-command (coordinates-list &rest args)
   (cons
    (svg--path-command-symbol 'm args)
-   (apply 'append
-          (mapcar
-           (lambda (coordinates)
-             (list (car coordinates) (cdr coordinates)))
-           coordinates-list))))
+   (mapcan
+    (lambda (coordinates)
+      (list (car coordinates) (cdr coordinates)))
+    coordinates-list)))
 
 (defun svg--closepath-command (&rest args)
   (list (svg--path-command-symbol 'z args)))
@@ -392,11 +389,10 @@ This is in contrast to merely setting it to 0."
 (defun svg--lineto-command (coordinates-list &rest args)
   (cons
    (svg--path-command-symbol 'l args)
-   (apply 'append
-          (mapcar
-           (lambda (coordinates)
-             (list (car coordinates) (cdr coordinates)))
-           coordinates-list))))
+   (mapcan
+    (lambda (coordinates)
+      (list (car coordinates) (cdr coordinates)))
+    coordinates-list)))
 
 (defun svg--horizontal-lineto-command (coordinate-list &rest args)
   (cons
@@ -411,24 +407,24 @@ This is in contrast to merely setting it to 0."
 (defun svg--curveto-command (coordinates-list &rest args)
   (cons
    (svg--path-command-symbol 'c args)
-   (apply 'append coordinates-list)))
+   (apply #'append coordinates-list)))
 
 (defun svg--smooth-curveto-command (coordinates-list &rest args)
   (cons
    (svg--path-command-symbol 's args)
-   (apply 'append coordinates-list)))
+   (apply #'append coordinates-list)))
 
 (defun svg--quadratic-bezier-curveto-command (coordinates-list
                                               &rest args)
   (cons
    (svg--path-command-symbol 'q args)
-   (apply 'append coordinates-list)))
+   (apply #'append coordinates-list)))
 
 (defun svg--smooth-quadratic-bezier-curveto-command (coordinates-list
                                                      &rest args)
   (cons
    (svg--path-command-symbol 't args)
-   (apply 'append coordinates-list)))
+   (apply #'append coordinates-list)))
 
 (defun svg--eval-path-command (command default-relative)
   (cl-letf
@@ -450,7 +446,7 @@ This is in contrast to merely setting it to 0."
         #'svg--elliptical-arc-command)
        (extended-command (append command (list :default-relative
                                                default-relative))))
-    (mapconcat 'prin1-to-string (apply extended-command) " ")))
+    (mapconcat #'prin1-to-string (apply extended-command) " ")))
 
 (defun svg-path (svg commands &rest args)
   "Add the outline of a shape to SVG according to COMMANDS.
@@ -459,7 +455,7 @@ modifiers.  If :relative is t, then coordinates are 
relative to
 the last position, or -- initially -- to the origin."
   (let* ((default-relative (plist-get args :relative))
          (stripped-args (svg--plist-delete args :relative))
-         (d (mapconcat 'identity
+         (d (mapconcat #'identity
                        (mapcar
                         (lambda (command)
                           (svg--eval-path-command command



reply via email to

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