hyperbole-users
[Top][All Lists]
Advanced

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

Re: implicit links


From: Robert Weiner
Subject: Re: implicit links
Date: Tue, 18 May 2021 21:27:09 -0400

Here is the fix/patch for your problem.  -- Bob

Copy all of the following lines to the *scratch* buffer in your Emacs
and follow the directions:

Activate the following link with M-RETURN:   <link-to-string-match "link-to-ebut" 1 "${hyperb:dir}/hactypes.el">
Replace the defact you see in the file with
  the one defined below.
Then byte-compile and reload the file
by activating the following key series:      {C-x b hactypes.el RET M-: (byte-compile-buffer t) RET}


(defact link-to-ebut (key &optional key-file)
  "Perform action given by an explicit button, specified by KEY and optional KEY-FILE.
Interactively, KEY-FILE defaults to the current buffer's file name."
  (interactive
   (let (but-lbl
         but-file)
     (while (cond ((setq but-file
                         (read-file-name
                          "File of button to link to: " nil nil t))
                   (if (string-equal but-file "")
                       (progn (beep) t)))
                  ((not (file-readable-p but-file))
                   (message "(link-to-ebut): You cannot read `%s'."
                            but-file)
                   (beep) (sit-for 3))))
     (list (progn
             (find-file-noselect but-file)
             (while (string-equal "" (setq but-lbl
                                           (hargs:read-match
                                            "Button to link to: "
                                            (ebut:alist but-file)
                                            nil nil nil 'ebut)))
               (beep))
             (ebut:label-to-key but-lbl))
           but-file)))
  (let (but
        normalized-file)
    (if key-file
        (setq normalized-file (hpath:normalize key-file))
      (setq normalized-file buffer-file-name))

    (if (setq but (when normalized-file (ebut:get key nil normalized-file)))
        (hbut:act but)
      (hypb:error "(link-to-ebut): No button `%s' in `%s'"
                  (ebut:key-to-label key)
                  key-file))))

reply via email to

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