emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/hyperbole a4f880c 01/25: hbdata.el (hbdata:write): Make


From: Stefan Monnier
Subject: [elpa] externals/hyperbole a4f880c 01/25: hbdata.el (hbdata:write): Make first ebut in dir work immediately
Date: Tue, 22 Sep 2020 10:29:25 -0400 (EDT)

branch: externals/hyperbole
commit a4f880ce4692a8fa3ee2c171987835df9eea7be2
Author: Bob Weiner <rsw@gnu.org>
Commit: Bob Weiner <rsw@gnu.org>

    hbdata.el (hbdata:write): Make first ebut in dir work immediately
---
 Changes   |  7 ++++++-
 DEMO      |  2 +-
 hbdata.el | 42 +++++++++++++++++++++++-------------------
 3 files changed, 30 insertions(+), 21 deletions(-)

diff --git a/Changes b/Changes
index 33fcf06..e6af09f 100644
--- a/Changes
+++ b/Changes
@@ -1,3 +1,8 @@
+2020-07-20  Bob Weiner  <rsw@gnu.org>
+
+* hbdata.el (hbdata:write): Fixed so first explicit button created in a 
directory
+    works before saving its source buffer (by saving the directory .hypb file).
+
 2020-07-08  Bob Weiner  <rsw@gnu.org>
 
 * hbut.el (hbut:delete, ibut:delete): Added.
@@ -19,7 +24,7 @@ V7.1.3 changes ^^^^:
     clickable Emacs buttons and proper highlighting when dragging mouse-1.  
This also allowed
     for deletion of Info-mode-map mouse-1 bindings.
 
- 2020-07-05  Bob Weiner  <rsw@gnu.org>
+2020-07-05  Bob Weiner  <rsw@gnu.org>
 
 * hbut.el (ibut:to): Fix not handling ibut names by substituting ibut:label-p 
call for ibut:at-p.
 
diff --git a/DEMO b/DEMO
index 700f2ad..c48d7dd 100644
--- a/DEMO
+++ b/DEMO
@@ -419,7 +419,7 @@ Hyperbole provides a history command that returns you to 
previous button
 locations in the reverse order of the way you traverse them.  It actually
 restores your complete frame and window configuration at the time of the
 button press.  You access it by selecting the Hist command from the top-level
-Hyperbole menu, C-h h h.  Remember this because you will want to use that
+Hyperbole menu, {C-h h h}.  Remember this because you will want to use that
 command to return to this DEMO later.
 
 
diff --git a/hbdata.el b/hbdata.el
index 1765263..a2d4481 100644
--- a/hbdata.el
+++ b/hbdata.el
@@ -358,19 +358,20 @@ one and returns buffer, otherwise returns nil."
         (buf (or (get-file-buffer file)
                  (and (or create existing-file)
                       (find-file-noselect file)))))
-    (if buf
-       (progn (set-buffer buf)
-              (or (verify-visited-file-modtime (get-file-buffer file))
-                  (cond ((yes-or-no-p
-                          "Hyperbole button data file has changed, read new 
contents? ")
-                         (revert-buffer t t)
-                         )))
-              (or (= (point-max) 1) (eq (char-after 1) ?\^L)
-                  (error "File %s is not a valid Hyperbole button data table" 
file))
-              (or (equal (buffer-name) file) (rename-buffer file))
-              (setq buffer-read-only nil)
-              (or existing-file (hbmap:dir-add (file-name-directory file)))
-              buf))))
+    (when buf
+      (set-buffer buf)
+      (unless (verify-visited-file-modtime (get-file-buffer file))
+       (cond ((yes-or-no-p
+               "Hyperbole button data file has changed, read new contents? ")
+              (revert-buffer t t))))
+      (or (= (point-max) 1) (eq (char-after 1) ?\^L)
+         (error "File %s is not a valid Hyperbole button data table" file))
+      (unless (equal (buffer-name) file)
+       (rename-buffer file))
+      (setq buffer-read-only nil)
+      (unless existing-file
+       (hbmap:dir-add (file-name-directory file)))
+      buf)))
 
 
 (defun hbdata:to-entry-buf (key-src &optional directory create)
@@ -419,15 +420,18 @@ a button instance string to append to button label or t 
when first instance.
 On failure, return nil."
   (let ((cons (hbdata:build orig-lbl-key but-sym))
        entry lbl-instance)
-    (if (or (and buffer-file-name
-                (not (file-writable-p buffer-file-name)))
-           (null cons))
-       nil
+    (unless (or (and buffer-file-name (not (file-writable-p buffer-file-name)))
+               (null cons))
       (setq entry (car cons) lbl-instance (cdr cons))
       (prin1 entry (current-buffer))
       (terpri (current-buffer))
-      (or lbl-instance t)
-      )))
+      (when buffer-file-name (not (file-exists-p buffer-file-name))
+       ;; This is the first explicit button created in this
+       ;; directory, so .hypb does not yet exist and unless it is saved
+       ;; here, the first explicit button won't work until its source
+       ;; buffer is saved.
+       (save-buffer))
+      (or lbl-instance t))))
 
 
 ;;; ************************************************************************



reply via email to

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