emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] scratch/gnus-cloud 5945c52 47/61: Merge branch 'master' of


From: Teodor Zlatanov
Subject: [Emacs-diffs] scratch/gnus-cloud 5945c52 47/61: Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs
Date: Fri, 1 Jul 2016 17:37:56 +0000 (UTC)

branch: scratch/gnus-cloud
commit 5945c529cf5634e0ca92f961a2d2dedc2b29668c
Merge: 0456139 1f55925
Author: Ted Zlatanov <address@hidden>
Commit: Ted Zlatanov <address@hidden>

    Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs
---
 doc/lispref/display.texi |   22 ++++++++++++++++++++++
 doc/lispref/text.texi    |    3 +++
 lisp/dom.el              |   11 +++++++++++
 lisp/net/shr.el          |    6 ++++--
 lisp/svg.el              |   42 +++++++++++++++++++++++++++++++-----------
 lisp/vc/diff-mode.el     |   32 ++++++++++++++++----------------
 6 files changed, 87 insertions(+), 29 deletions(-)

diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi
index 575cad8..b7a6b57 100644
--- a/doc/lispref/display.texi
+++ b/doc/lispref/display.texi
@@ -5350,6 +5350,24 @@ that describe the outer circumference of the polygon.
 @end lisp
 @end defun
 
address@hidden svg-text svg text &rest args
+Add a text to @var{svg}.
+
address@hidden
+(svg-text
+ svg "This is a text"
+ :font-size "40"
+ :font-weight "bold"
+ :stroke "black"
+ :fill "white"
+ :font-family "impact"
+ :letter-spacing "4pt"
+ :x 300
+ :y 400
+ :stroke-width 1)
address@hidden lisp
address@hidden defun
+
 @defun svg-embed svg image image-type datap &rest args
 Add an embedded (raster) image to @var{svg}.  If @var{datap} is
 @code{nil}, @var{IMAGE} should be a file name; if not, it should be a
@@ -5363,6 +5381,10 @@ binary string containing the image data.  
@var{image-type} should be a
 @end lisp
 @end defun
 
address@hidden svg-remove svg id
+Remove the element with identifier @code{id} from the @code{svg}.
address@hidden defun
+
 Finally, the @code{svg-image} takes an SVG object as its parameter and
 returns an image object suitable for use in functions like
 @code{insert-image}.  Here's a complete example that creates and
diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi
index 43d4945..4dc943f 100644
--- a/doc/lispref/text.texi
+++ b/doc/lispref/text.texi
@@ -4614,6 +4614,9 @@ to be inserted between the textual elements.
 
 @item dom-parent @var{dom} @var{node}
 Return the parent of @var{node} in @var{dom}.
+
address@hidden dom-remove @var{dom} @var{node}
+Remove @var{node} from @var{dom}.
 @end table
 
 The following are functions for altering the @acronym{DOM}.
diff --git a/lisp/dom.el b/lisp/dom.el
index 03fe759..cf3a02a 100644
--- a/lisp/dom.el
+++ b/lisp/dom.el
@@ -139,6 +139,16 @@ ATTRIBUTE would typically be `class', `id' or the like."
        (cons dom matches)
       matches)))
 
+(defun dom-remove-node (dom node)
+  "Remove NODE from DOM."
+  ;; If we're removing the top level node, just return nil.
+  (dolist (child (dom-children dom))
+    (cond
+     ((eq node child)
+      (delq node dom))
+     ((not (stringp child))
+      (dom-remove-node child node)))))
+
 (defun dom-parent (dom node)
   "Return the parent of NODE in DOM."
   (if (memq node (dom-children dom))
@@ -151,6 +161,7 @@ ATTRIBUTE would typically be `class', `id' or the like."
       result)))
 
 (defun dom-previous-sibling (dom node)
+  "Return the previous sibling of NODE in DOM."
   (when-let (parent (dom-parent dom node))
     (let ((siblings (dom-children parent))
          (previous nil))
diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index 9d42fde..6b19983 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -296,8 +296,10 @@ image under point instead.
 If called twice, then try to fetch the URL and see whether it
 redirects somewhere else."
   (interactive "P")
-  (let ((url (or (get-text-property (point) 'shr-url)
-                (get-text-property (point) 'image-url))))
+  (let ((url (if image-url
+                 (get-text-property (point) 'image-url)
+               (or (get-text-property (point) 'shr-url)
+                   (get-text-property (point) 'image-url)))))
     (cond
      ((not url)
       (message "No URL under point"))
diff --git a/lisp/svg.el b/lisp/svg.el
index c33b092..a92c6df 100644
--- a/lisp/svg.el
+++ b/lisp/svg.el
@@ -27,6 +27,7 @@
 (require 'cl-lib)
 (require 'xml)
 (require 'dom)
+(require 'subr-x)
 
 (defun svg-create (width height &rest args)
   "Create a new, empty SVG image with dimensions WIDTHxHEIGHT.
@@ -149,13 +150,22 @@ otherwise.  IMAGE-TYPE should be a MIME image type, like
     `((xlink:href . ,(svg--image-data image image-type datap))
       ,@(svg--arguments svg args)))))
 
+(defun svg-text (svg text &rest args)
+  "Add TEXT to SVG."
+  (svg--append
+   svg
+   (dom-node
+    'text
+    `(,@(svg--arguments svg args))
+    text)))
+
 (defun svg--append (svg node)
   (let ((old (and (dom-attr node 'id)
                  (dom-by-id svg
                              (concat "\\`" (regexp-quote (dom-attr node 'id))
                                      "\\'")))))
     (if old
-       (dom-set-attributes old (dom-attributes node))
+       (setcdr (car old) (cdr node))
       (dom-append-child svg node)))
   (svg-possibly-update-image svg))
 
@@ -237,16 +247,26 @@ If the SVG is later changed, the image will also be 
updated."
 
 (defun svg-print (dom)
   "Convert DOM into a string containing the xml representation."
-  (insert (format "<%s" (car dom)))
-  (dolist (attr (nth 1 dom))
-    ;; Ignore attributes that start with a colon.
-    (unless (= (aref (format "%s" (car attr)) 0) ?:)
-      (insert (format " %s=\"%s\"" (car attr) (cdr attr)))))
-  (insert ">")
-  (dolist (elem (nthcdr 2 dom))
-    (insert " ")
-    (svg-print elem))
-  (insert (format "</%s>" (car dom))))
+  (if (stringp dom)
+      (insert dom)
+    (insert (format "<%s" (car dom)))
+    (dolist (attr (nth 1 dom))
+      ;; Ignore attributes that start with a colon.
+      (unless (= (aref (format "%s" (car attr)) 0) ?:)
+        (insert (format " %s=\"%s\"" (car attr) (cdr attr)))))
+    (insert ">")
+    (dolist (elem (nthcdr 2 dom))
+      (insert " ")
+      (svg-print elem))
+    (insert (format "</%s>" (car dom)))))
+
+(defun svg-remove (svg id)
+  "Remove the element identified by ID from SVG."
+  (when-let ((node (car (dom-by-id
+                         svg
+                         (concat "\\`" (regexp-quote id)
+                                 "\\'")))))
+    (dom-remove-node svg node)))
 
 (provide 'svg)
 
diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el
index 43ff9e0..58498cb 100644
--- a/lisp/vc/diff-mode.el
+++ b/lisp/vc/diff-mode.el
@@ -371,22 +371,22 @@ and the face `diff-added' for added lines.")
 
 (defvar diff-font-lock-keywords
   `((,(concat "\\(" diff-hunk-header-re-unified "\\)\\(.*\\)$")
-     (1 diff-hunk-header) (6 diff-function))
+     (1 'diff-hunk-header) (6 'diff-function))
     ("^\\(\\*\\{15\\}\\)\\(.*\\)$"                        ;context
-     (1 diff-hunk-header) (2 diff-function))
-    ("^\\*\\*\\* .+ \\*\\*\\*\\*". diff-hunk-header) ;context
-    (,diff-context-mid-hunk-header-re . diff-hunk-header) ;context
-    ("^[0-9,]+[acd][0-9,]+$"     . diff-hunk-header) ;normal
-    ("^---$"                     . diff-hunk-header) ;normal
+     (1 'diff-hunk-header) (2 'diff-function))
+    ("^\\*\\*\\* .+ \\*\\*\\*\\*". 'diff-hunk-header) ;context
+    (,diff-context-mid-hunk-header-re . 'diff-hunk-header) ;context
+    ("^[0-9,]+[acd][0-9,]+$"     . 'diff-hunk-header) ;normal
+    ("^---$"                     . 'diff-hunk-header) ;normal
     ;; For file headers, accept files with spaces, but be careful to rule
     ;; out false-positives when matching hunk headers.
     ("^\\(---\\|\\+\\+\\+\\|\\*\\*\\*\\) \\([^\t\n]+?\\)\\(?:\t.*\\| 
\\(\\*\\*\\*\\*\\|----\\)\\)?\n"
-     (0 diff-header)
-     (2 (if (not (match-end 3)) diff-file-header) prepend))
+     (0 'diff-header)
+     (2 (if (not (match-end 3)) 'diff-file-header) prepend))
     ("^\\([-<]\\)\\(.*\n\\)"
-     (1 diff-indicator-removed-face) (2 diff-removed))
+     (1 diff-indicator-removed-face) (2 'diff-removed))
     ("^\\([+>]\\)\\(.*\n\\)"
-     (1 diff-indicator-added-face) (2 diff-added))
+     (1 diff-indicator-added-face) (2 'diff-added))
     ("^\\(!\\)\\(.*\n\\)"
      (1 (if diff-use-changed-face
            diff-indicator-changed-face
@@ -399,20 +399,20 @@ and the face `diff-added' for added lines.")
                  diff-indicator-added-face
                diff-indicator-removed-face)))))
      (2 (if diff-use-changed-face
-           diff-changed
+           'diff-changed
          ;; Otherwise, use the same method as above.
          (save-match-data
            (let ((limit (save-excursion (diff-beginning-of-hunk))))
              (if (save-excursion (re-search-backward 
diff-context-mid-hunk-header-re limit t))
-                 diff-added
-               diff-removed))))))
+                 'diff-added
+               'diff-removed))))))
     ("^\\(?:Index\\|revno\\): \\(.+\\).*\n"
-     (0 diff-header) (1 diff-index prepend))
-    ("^Only in .*\n" . diff-nonexistent)
+     (0 'diff-header) (1 'diff-index prepend))
+    ("^Only in .*\n" . 'diff-nonexistent)
     ("^\\(#\\)\\(.*\\)"
      (1 font-lock-comment-delimiter-face)
      (2 font-lock-comment-face))
-    ("^[^-=+*!<>#].*\n" (0 diff-context))))
+    ("^[^-=+*!<>#].*\n" (0 'diff-context))))
 
 (defconst diff-font-lock-defaults
   '(diff-font-lock-keywords t nil nil nil (font-lock-multiline . nil)))



reply via email to

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