blob: cd6a1410fc67e4ff6815c0eb1cc3bc25a7492762 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
;;; hui-register.el --- register support for Hyperbole -*- lexical-binding: t; -*-
;;
;; Author: Mats Lidell
;;
;; Orig-Date: 6-Oct-91 at 03:42:38
;; Last-Mod: 18-Sep-22 at 00:40:52 by Mats Lidell
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
;; Copyright (C) 1991-2022 Free Software Foundation, Inc.
;; See the "HY-COPY" file for license information.
;;
;; This file is part of GNU Hyperbole.
;;; Code:
;;; Commentary:
;;
;; Implements a struct for ebut and ibut, a content type of a
;; register. See "(Emacs) Registers"
;;
(eval-when-compile (require 'cl-lib))
(require 'hbut)
;;; ************************************************************************
;;; Public functions
;;; ************************************************************************
(cl-defstruct hui-register-but
"Button register struct."
label file mpos link)
;;;###autoload
(defun hui-register-struct-at-point ()
"Make a Hyperbole link to button register struct for button at point."
(let* ((ebut-label (ebut:label-p))
(ibut-label (ibut:label-p))
(label (or ebut-label ibut-label)))
(unless label
(hypb:error "Point must be at a Hyperbole button"))
(make-hui-register-but
:label label
:file (buffer-file-name)
:mpos (point-marker)
:link (if ebut-label 'link-to-ebut 'link-to-ibut))))
;;; ************************************************************************
;;; Private functions
;;; ************************************************************************
(cl-defmethod register-val-jump-to ((val hui-register-but) _arg)
"Move point to location for Hyperbole button stored in VAL."
(let ((buf (marker-buffer (hui-register-but-mpos val)))
(pos (marker-position (hui-register-but-mpos val))))
(unless buf
(user-error "That Hyperbole button's buffer no longer exists"))
(switch-to-buffer buf)
(goto-char pos)))
(cl-defmethod register-val-describe ((val hui-register-but) _verbose)
"Print description of Hyperbole button register value VAL to `standard-output'."
(princ "Hyperbole button\n ")
(princ (format "%s in file %s\n"
(hui-register-but-label val)
(hui-register-but-file val))))
(cl-defmethod register-val-insert ((val hui-register-but))
"Insert an ebut linking to the register button stored in VAL."
(ebut:program (hui-register-but-label val)
(hui-register-but-link val)
(hui-register-but-label val)
(hui-register-but-file val)))
(provide 'hui-register)
;;; hui-register.el ends here
|