Skip to content

Commit 540c4a3

Browse files
authored
add hypb smerge (#716)
1 parent 2648dd8 commit 540c4a3

3 files changed

Lines changed: 46 additions & 9 deletions

File tree

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
2025-04-26 Mats Lidell <matsl@gnu.org>
22

3+
* hibtypes.el (smerge): Add ibut smerge.
4+
5+
* hui-mouse.el (smart-magit): Add smerge support in magit-status-mode.
6+
37
* hywiki.el (hywiki-word-face-at-p): Add optional pos to enable reuse.
48

59
* test/hy-test-helpers.el (hy-test-word-face-at-region): Simplify by

hibtypes.el

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
;; Author: Bob Weiner
44
;;
55
;; Orig-Date: 19-Sep-91 at 20:45:31
6-
;; Last-Mod: 19-Apr-25 at 17:51:14 by Bob Weiner
6+
;; Last-Mod: 26-Apr-25 at 10:19:22 by Mats Lidell
77
;;
88
;; SPDX-License-Identifier: GPL-3.0-or-later
99
;;
@@ -45,6 +45,7 @@
4545
(require 'org-macs) ;; for org-uuid-regexp
4646
(require 'subr-x) ;; for string-trim
4747
(require 'thingatpt)
48+
(eval-when-compile (require 'smerge-mode))
4849

4950
;;; ************************************************************************
5051
;;; Public declarations
@@ -1737,6 +1738,26 @@ If a boolean function or variable, display its value."
17371738
;; If you want to to disable ALL Hyperbole support within Org major
17381739
;; and minor modes, set the custom option `hsys-org-enable-smart-keys' to nil.
17391740

1741+
;;; ========================================================================
1742+
;;; Resolve merge conflicts in smerge-mode
1743+
;;; ========================================================================
1744+
1745+
(defib smerge ()
1746+
"Act on conflicts in merge buffers, i.e. when smerge-mode is active."
1747+
(when (bound-and-true-p smerge-mode)
1748+
(let (op)
1749+
(save-excursion
1750+
(beginning-of-line)
1751+
(cond ((looking-at smerge-end-re)
1752+
(setq op 'smerge-keep-lower))
1753+
((looking-at smerge-begin-re)
1754+
(setq op 'smerge-keep-upper))
1755+
((looking-at smerge-lower-re)
1756+
(setq op 'smerge-keep-all))))
1757+
(when op
1758+
(ibut:label-set (match-string-no-properties 0) (match-beginning 0) (match-end 0))
1759+
(hact op)))))
1760+
17401761
(run-hooks 'hibtypes-end-load-hook)
17411762
(provide 'hibtypes)
17421763

hui-mouse.el

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
;; Author: Bob Weiner
44
;;
55
;; Orig-Date: 04-Feb-89
6-
;; Last-Mod: 15-Apr-25 at 12:51:50 by Mats Lidell
6+
;; Last-Mod: 25-Apr-25 at 23:35:04 by Mats Lidell
77
;;
88
;; SPDX-License-Identifier: GPL-3.0-or-later
99
;;
@@ -1575,13 +1575,25 @@ If key is pressed:
15751575
point (\"RET\" key binding) but display based on the value of
15761576
`hpath:display-where'."
15771577
(interactive)
1578-
(cond ((last-line-p)
1579-
(call-interactively (key-binding "q")))
1580-
((eolp)
1581-
(smart-scroll-up))
1582-
(t
1583-
(let ((magit-display-buffer-function #'hpath:display-buffer))
1584-
(call-interactively #'smart-magit-tab)))))
1578+
(let (op)
1579+
(cond ((last-line-p)
1580+
(call-interactively (key-binding "q")))
1581+
((eolp)
1582+
(smart-scroll-up))
1583+
((and
1584+
(eq major-mode 'magit-status-mode)
1585+
(save-excursion
1586+
(beginning-of-line)
1587+
(cond ((looking-at (regexp-quote "++>>>>>>>"))
1588+
(setq op 'magit-smerge-keep-lower))
1589+
((looking-at (regexp-quote "++<<<<<<<"))
1590+
(setq op 'magit-smerge-keep-upper))
1591+
((looking-at (regexp-quote "++======="))
1592+
(setq op 'magit-smerge-keep-all)))))
1593+
(call-interactively op))
1594+
(t
1595+
(let ((magit-display-buffer-function #'hpath:display-buffer))
1596+
(call-interactively #'smart-magit-tab))))))
15851597

15861598
(defun smart-magit-assist ()
15871599
"Use an assist key or mouse key to jump to source and to hide/show changes.

0 commit comments

Comments
 (0)