[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/why-this 88ee5f9746 27/59: Add Mercurial backend
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/why-this 88ee5f9746 27/59: Add Mercurial backend |
Date: |
Sun, 27 Nov 2022 16:02:51 -0500 (EST) |
branch: elpa/why-this
commit 88ee5f974693a04a19ab76f731dae221146af33a
Author: Akib Azmain Turja <akib@disroot.org>
Commit: Akib Azmain Turja <akib@disroot.org>
Add Mercurial backend
---
why-this.el | 53 +++++++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 49 insertions(+), 4 deletions(-)
diff --git a/why-this.el b/why-this.el
index 72761fc673..d5df6905bc 100644
--- a/why-this.el
+++ b/why-this.el
@@ -1,4 +1,4 @@
-;;; why-this.el --- Minor mode for showing why the current line was changed
-*- lexical-binding: t -*-
+;;; why-this.el --- Show why the current line contains this -*-
lexical-binding: t -*-
;; Copyright (C) 2022 Akib Azmain Turja.
@@ -25,7 +25,10 @@
;;; Commentary:
-;; Show the when and why the current line was last changed.
+;; why-this shows when and why the current line was last changed. Enable
+;; with M-x why-this-mode. Or see why a line was change without enabling
+;; with M-x why-this. See editing history of whole file with heat map with
+;; M-x why-this-annotate.
;;; Code:
@@ -39,7 +42,8 @@
:link '(url-link "https://codeberg.org/akib/emacs-why-this")
:prefix "why-this-")
-(defcustom why-this-backends '(why-this-backend-git)
+(defcustom why-this-backends '(why-this-git
+ why-this-hg)
"List of enabled backends."
:type '(repeat (function :tag "Backend"))
:package-version '(why-this "1.0")
@@ -545,7 +549,7 @@ Actually the supported backend is returned."
:group 'why-this
(add-to-invisibility-spec '(ellipsis . t)))
-(defun why-this-backend-git (cmd &rest args)
+(defun why-this-git (cmd &rest args)
"Git backend for Why-This mode.
Do CMD with ARGS."
@@ -625,5 +629,46 @@ Do CMD with ARGS."
(funcall add-uncommitted))
line-data)))))
+(defun why-this-hg (cmd &rest args)
+ "Mercurial backend for Why-This mode.
+
+Do CMD with ARGS."
+ (pcase cmd
+ ('supported-p
+ (and (buffer-file-name)
+ (string= "t" (shell-command-to-string
+ (format "hg annotate \"%s\" --template \"t\""
+ (buffer-file-name))))))
+ ('line-data
+ (when (> (- (nth 1 args) (nth 0 args)) 0)
+ (let ((output
+ (car
+ (read-from-string
+ (shell-command-to-string
+ (format
+ (concat
+ "hg annotate \"%s\" --template \"({lines %% '(:id"
+ " {rev} :author \\\"{person(user)}\\\" :time"
+ " ({hgdate(date)}) :message \\\"{sub(\\\"\\\\\\\"\\\","
+ " \\\"\\\\\\\\\\\\\\\"\\\", sub(\\\"\\n.*\\\","
+ " \\\"\\\", desc))}\\\") '})\"")
+ (buffer-file-name))))))
+ data)
+ (dolist (i (number-sequence (1- (nth 1 args)) (nth 0 args) -1))
+ (if (<= i (length output))
+ (let ((plist (nth (1- i) output)))
+ (plist-put plist :time (time-convert
+ (car (plist-get plist :time))))
+ (push plist data))
+ (setq data
+ (append data
+ (list
+ (list
+ :id nil
+ :author user-full-name
+ :time (current-time)
+ :message "Uncommitted changes"))))))
+ data)))))
+
(provide 'why-this)
;;; why-this.el ends here
- [nongnu] elpa/why-this 9f656b59dd 33/59: Change package summary, (continued)
- [nongnu] elpa/why-this 9f656b59dd 33/59: Change package summary, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this 3497115c2b 35/59: Don't store unnecessary data, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this 7a2e4af450 19/59: Rewrite Git backend, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this 41fe21da73 15/59: Fontify before annotate, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this 006ea3864a 13/59: Fix Git backend 'supported-p command, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this 0c1686d8d3 12/59: Fix misspelled word "annonate", ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this 73398fb7cb 04/59: Don't interfere with writing, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this 2093cadb03 06/59: Add relative time support and fix Git backend, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this c2a21ca13d 01/59: Core implementation without any backends, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this b26fca274d 21/59: Add COPYING, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this 88ee5f9746 27/59: Add Mercurial backend,
ELPA Syncer <=
- [nongnu] elpa/why-this 624e98bc78 23/59: Fix relative time calculation, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this 45dc65ccb1 26/59: Fix timezone problem in Git backend, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this 236f8fd225 09/59: Fix problem when enabled on multiple buffers, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this dc5fc19b75 30/59: Allow changing time format, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this b8e612d4cb 20/59: Show tooltip on hover, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this aa15ec4fcd 29/59: Add support for minimum column of message, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this 3e3f852835 38/59: Fix README, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this 357cfa7e1e 34/59: Ensure that temporary file created by Git backend is deleted, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this f3d1e47b80 37/59: Fix indentation, ELPA Syncer, 2022/11/27
- [nongnu] elpa/why-this 1c8a4fbfd5 31/59: Update screenshots, ELPA Syncer, 2022/11/27