[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master c2b86af 5/5: Merge branch 'master' of git.sv.gnu.org:/srv/
From: |
Rocky Bernstein |
Subject: |
[elpa] master c2b86af 5/5: Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs/elpa |
Date: |
Thu, 4 Aug 2016 03:03:26 +0000 (UTC) |
branch: master
commit c2b86afdf5df89981ff740520c3ac3a976c9a445
Merge: 20947cb a275e71
Author: rocky <address@hidden>
Commit: rocky <address@hidden>
Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs/elpa
---
packages/diffview/Makefile | 13 ++
packages/diffview/README.md | 59 ++++++
packages/diffview/diffview.el | 200 +++++++++++++++++++++
packages/diffview/screenshots/diffview-after.png | Bin 0 -> 199810 bytes
packages/diffview/screenshots/diffview-before.png | Bin 0 -> 184048 bytes
packages/el-search/el-search.el | 13 ++
packages/poker/poker.el | 13 +-
7 files changed, 294 insertions(+), 4 deletions(-)
diff --git a/packages/diffview/Makefile b/packages/diffview/Makefile
new file mode 100644
index 0000000..a422376
--- /dev/null
+++ b/packages/diffview/Makefile
@@ -0,0 +1,13 @@
+README.md: make-readme-markdown.el diffview.el
+ emacs --script $< < diffview.el >$@
+
+ifeq ($(LOCAL),1)
+make-readme-markdown.el:
+ cp -v ../make-readme-markdown/make-readme-markdown.el .
+else
+make-readme-markdown.el:
+ wget -q -O $@
https://raw.github.com/mgalgs/make-readme-markdown/master/make-readme-markdown.el
+endif
+
+.INTERMEDIATE: make-readme-markdown.el
+.PHONY: README.md
diff --git a/packages/diffview/README.md b/packages/diffview/README.md
new file mode 100644
index 0000000..d64002d
--- /dev/null
+++ b/packages/diffview/README.md
@@ -0,0 +1,59 @@
+## diffview.el
+*View diffs in side-by-side format*
+
+---
+[![License
GPLv3](https://img.shields.io/badge/license-GPL_v3-green.svg)](http://www.gnu.org/licenses/gpl-3.0.html)
+[![MELPA](http://melpa.org/packages/diffview-badge.svg)](http://melpa.org/#/diffview)
+[![MELPA
Stable](http://stable.melpa.org/packages/diffview-badge.svg)](http://stable.melpa.org/#/diffview)
+
+Render a unified diff (top/bottom) in an easy-to-comprehend side-by-side
+format. This comes in handy for reading patches from mailing lists (or
+from whencever you might acquire them).
+
+### Installation
+
+
+ M-x package-install diffview
+
+### Usage
+
+
+The following functions are provided for launching a side-by-side diff:
+
+* `diffview-current` : View the current diff buffer side-by-side
+* `diffview-region` : View the current diff region side-by-side
+* `diffview-message` : View the current email message (which presumably
+ contains a patch) side-by-side
+
+
+### Screenshots
+
+
+Before:
+<img
src="https://raw.github.com/mgalgs/diffview-mode/master/screenshots/diffview-before.png">
+
+After:
+<img
src="https://raw.github.com/mgalgs/diffview-mode/master/screenshots/diffview-after.png">
+
+### Function Documentation
+
+
+#### `(diffview-current)`
+
+Show current diff buffer in a side-by-side view.
+
+#### `(diffview-region)`
+
+Show current diff region in a side-by-side view.
+
+#### `(diffview-message)`
+
+Show `message-mode` buffer in a side-by-side view.
+
+This is useful for reading patches from mailing lists.
+
+-----
+<div style="padding-top:15px;color: #d0d0d0;">
+Markdown README file generated by
+<a
href="https://github.com/mgalgs/make-readme-markdown">make-readme-markdown.el</a>
+</div>
diff --git a/packages/diffview/diffview.el b/packages/diffview/diffview.el
new file mode 100644
index 0000000..2455c67
--- /dev/null
+++ b/packages/diffview/diffview.el
@@ -0,0 +1,200 @@
+;;; diffview.el --- View diffs in side-by-side format
+
+;; Copyright (C) 2013-2016 Free Software Foundation, Inc.
+
+;; Author: Mitchel Humpherys <address@hidden>
+;; Maintainer: Mitchel Humpherys <address@hidden>
+;; Keywords: convenience, diff
+;; Version: 1.0
+;; URL: https://github.com/mgalgs/diffview-mode
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;;
+;; Render a unified diff (top/bottom) in an easy-to-comprehend side-by-side
+;; format. This comes in handy for reading patches from mailing lists (or
+;; from whencever you might acquire them).
+;;
+;;; Installation:
+;;
+;; M-x package-install diffview
+;;
+;;; Usage:
+;;
+;; The following functions are provided for launching a side-by-side diff:
+;;
+;; o `diffview-current' : View the current diff buffer side-by-side
+;; o `diffview-region' : View the current diff region side-by-side
+;; o `diffview-message' : View the current email message (which presumably
+;; contains a patch) side-by-side
+;;
+;;
+;;; Screenshots:
+;;
+;; Before:
+;;
https://raw.github.com/mgalgs/diffview-mode/master/screenshots/diffview-before.png
+;;
+;; After:
+;;
https://raw.github.com/mgalgs/diffview-mode/master/screenshots/diffview-after.png
+;;
+;;; Code:
+
+(require 'message)
+
+(defun diffview--print-all-lines-to-buffer (lines buffer-name)
+ "Prints each line in `LINES' to a buffer named `BUFFER-NAME'."
+ (let ((old-temp-buffer (get-buffer buffer-name)))
+ ;; (with-output-to-temp-buffer buffer-name
+ (when old-temp-buffer
+ (kill-buffer old-temp-buffer))
+ (with-current-buffer (get-buffer-create buffer-name)
+ (erase-buffer)
+ (dolist (line lines)
+ (insert line "\n")))))
+
+(defvar diffview--minus-bufname "*side-by-side-1*")
+(defvar diffview--plus-bufname "*side-by-side-2*")
+(defvar diffview--saved-wincfg nil)
+(defvar diffview--regexp-is-plus-line "^\\+\\([^+]\\{1\\}\\|$\\)"
+ "A + followed by one non + or the end of the line.")
+(defvar diffview--regexp-is-minus-line "^-\\([^-]\\{1\\}\\|$\\)"
+ "A - followed by one non - or the end of the line.")
+
+(defun diffview--view-string (input-string)
+ "Displays `INPUT-STRING' (a diff) in a side-by-side view."
+ (setq diffview--saved-wincfg (current-window-configuration))
+ (delete-other-windows)
+ (let (plus-lines
+ minus-lines
+ tmp-line
+ (current-state 'in-common)
+ (last-state 'in-common)
+ (current-lines-in-plus 0)
+ (current-lines-in-minus 0)
+ (total-lines 0)
+ (all-lines (split-string input-string "\n")))
+ (dolist (line all-lines)
+ (cond
+ ((string-match diffview--regexp-is-plus-line line)
+ (push line plus-lines)
+ (setq current-state 'in-plus)
+ (setq current-lines-in-plus (1+ current-lines-in-plus)))
+ ((string-match diffview--regexp-is-minus-line line)
+ (push line minus-lines)
+ (setq current-state 'in-minus)
+ (setq current-lines-in-minus (1+ current-lines-in-minus)))
+ ;; everything else must be common
+ (t
+ (push line plus-lines)
+ (push line minus-lines)
+ (setq current-state 'in-common)))
+
+ (setq total-lines (1+ total-lines))
+
+ ;; Process hunk state transitions
+ (when (not (equal current-state last-state))
+ ;; there's been a state change
+ (when (equal current-state 'in-common)
+ ;; we're transitioning out the +/- part of a hunk. We would
+ ;; like both sides to have the same number lines for this
+ ;; hunk, so we might need to fill one side or the other with
+ ;; empty lines.
+ (cond
+ ((> current-lines-in-plus current-lines-in-minus)
+ ;; need to fill minus
+ (setq tmp-line (pop minus-lines))
+ (dotimes (i (- current-lines-in-plus current-lines-in-minus))
+ (push "" minus-lines))
+ (push tmp-line minus-lines))
+ ((< current-lines-in-plus current-lines-in-minus)
+ ;; need to fill plus
+ (setq tmp-line (pop plus-lines))
+ (dotimes (i (- current-lines-in-minus current-lines-in-plus))
+ (push "" plus-lines))
+ (push tmp-line plus-lines)))
+
+ (setq current-lines-in-plus 0
+ current-lines-in-minus 0)))
+
+ (setq last-state current-state))
+
+ (diffview--print-all-lines-to-buffer (reverse minus-lines)
diffview--minus-bufname)
+ (diffview--print-all-lines-to-buffer (reverse plus-lines)
diffview--plus-bufname)
+
+ (switch-to-buffer diffview--minus-bufname nil t)
+ (goto-char (point-min))
+ (diffview-mode)
+
+ (split-window-right)
+ (other-window 1)
+
+ (switch-to-buffer diffview--plus-bufname nil t)
+ (goto-char (point-min))
+ (diffview-mode)
+
+ (scroll-all-mode)))
+
+;;;###autoload
+(defun diffview-current ()
+ "Show current diff buffer in a side-by-side view."
+ (interactive)
+ (diffview--view-string (buffer-string)))
+
+;;;###autoload
+(defun diffview-region ()
+ "Show current diff region in a side-by-side view."
+ (interactive)
+ (diffview--view-string (buffer-substring (point) (mark))))
+
+;;;###autoload
+(defun diffview-message ()
+ "Show `message-mode' buffer in a side-by-side view.
+
+This is useful for reading patches from mailing lists."
+ (interactive)
+ (let (beg end)
+ (save-excursion
+ (message-goto-body)
+ (search-forward-regexp "^---$")
+ (setq beg (1+ (point)))
+ (search-forward-regexp "^-- $")
+ (setq end (1+ (point)))
+ (diffview--view-string (buffer-substring beg end)))))
+
+
+
+;;; You probably don't want to invoke `diffview-mode' directly. Just use
+;;; one of the autoload functions above.
+
+(define-derived-mode diffview-mode special-mode "Diffview"
+ "Mode for viewing diffs side-by-side"
+ (setq font-lock-defaults '(diff-font-lock-keywords t nil nil nil
(font-lock-multiline . nil))))
+
+(defun diffview--quit ()
+ "Quit diffview and clean up diffview buffers."
+ (interactive)
+ (delete-other-windows)
+ (scroll-all-mode 0)
+ (let ((plusbuf (get-buffer diffview--plus-bufname))
+ (minusbuf (get-buffer diffview--minus-bufname)))
+ (if plusbuf (kill-buffer plusbuf))
+ (if minusbuf (kill-buffer minusbuf)))
+ (set-window-configuration diffview--saved-wincfg))
+
+(define-key diffview-mode-map (kbd "q") 'diffview--quit)
+
+(provide 'diffview)
+;;; diffview.el ends here
+;;
diff --git a/packages/diffview/screenshots/diffview-after.png
b/packages/diffview/screenshots/diffview-after.png
new file mode 100644
index 0000000..a59d9b5
Binary files /dev/null and b/packages/diffview/screenshots/diffview-after.png
differ
diff --git a/packages/diffview/screenshots/diffview-before.png
b/packages/diffview/screenshots/diffview-before.png
new file mode 100644
index 0000000..b33fca7
Binary files /dev/null and b/packages/diffview/screenshots/diffview-before.png
differ
diff --git a/packages/el-search/el-search.el b/packages/el-search/el-search.el
index d79af7f..cfdf875 100644
--- a/packages/el-search/el-search.el
+++ b/packages/el-search/el-search.el
@@ -659,6 +659,19 @@ MESSAGE are used to construct the error message."
;;;; Additional pattern type definitions
+;; Hint: we sometimes need to create (pcase) backquote forms with
+;; backquote. I do this like in this example:
+;;
+;; (let ((y 2))
+;; `(,'\` ((,'\, x) ,y)))
+;; ==> `(,x 2)
+;;
+;; Note that the backslashes are mandatory, else the reader macros are
+;; interpreted as composition of the respective operations, like in
+;;
+;; `(', (+ 1 2)) ==> ('3)
+
+
(defun el-search--split (matcher1 matcher2 list)
"Helper for the append pattern type.
diff --git a/packages/poker/poker.el b/packages/poker/poker.el
index c908bb6..61888ae 100644
--- a/packages/poker/poker.el
+++ b/packages/poker/poker.el
@@ -109,11 +109,16 @@ The highest possible value is therefore #x8CBA98 and the
lowest is #x053210."
(eq (nth 1 ranks) 3))
(setq ranks '(3 2 1 0 0)))
(eq (- (nth 0 ranks) (nth 4 ranks)) 4)))
- (flush (not (cdr (delete-dups (mapcar #'poker-card-suit
hand))))))
+ (flush (let ((suit (poker-card-suit (car hand)))
+ (tail (cdr hand)))
+ (while (and tail
+ (eq suit (poker-card-suit (car tail))))
+ (setq tail (cdr tail)))
+ (not tail))))
(cond ((and straight flush) #x800000)
- (straight #x400000)
- (flush #x500000)
- (t 0))))
+ (straight #x400000)
+ (flush #x500000)
+ (t 0))))
((equal rank-counts '(2 2 1)) #x200000)
((equal rank-counts '(3 1 1)) #x300000)
((equal rank-counts '(3 2)) #x600000)