3
3
; ; Author: Bob Weiner
4
4
; ;
5
5
; ; Orig-Date: 2-Apr-91
6
- ; ; Last-Mod: 3 -Oct-23 at 22:48:03 by Mats Lidell
6
+ ; ; Last-Mod: 22 -Oct-23 at 14:42:47 by Mats Lidell
7
7
; ;
8
8
; ; SPDX-License-Identifier: GPL-3.0-or-later
9
9
; ;
@@ -443,7 +443,31 @@ Return value of evaluation when a matching entry is found or nil."
443
443
(when end-func (funcall end-func)))))
444
444
rtn))
445
445
446
- (defun hbdata:to-entry-buf (key-src &optional directory create )
446
+ (defun hbdata:is-but-data-stored-in-buffer (key-src )
447
+ " True if we store but-data in the buffer rather than in a file."
448
+ ; ; Drafts of mail messages now have a buffer-file-name since they
449
+ ; ; are temporarily saved to a file until sent. But but-data still
450
+ ; ; should be stored in the mail buffer itself, so check explicitly
451
+ ; ; whether is a mail composition buffer in such cases.
452
+ (or (hmail:mode-is-p)
453
+ (and (get-buffer key-src)
454
+ (set-buffer key-src)
455
+ (not buffer-file-name))))
456
+
457
+ (defun hbdata:to-entry-in-buffer (create )
458
+ " Move point to end of line in but data in current buffer.
459
+ Note: Button buffer has no file attached. With optional CREATE,
460
+ if no such line exists, insert a new entry at the beginning of
461
+ the hbdata (which is created if necessary). Return t."
462
+ (if (hmail:hbdata-to-p) ; ; Might change the buffer
463
+ (setq buffer-read-only nil )
464
+ (when create
465
+ (setq buffer-read-only nil )
466
+ (insert " \n " hmail:hbdata-sep " \n " )))
467
+ (backward-char 1 )
468
+ t )
469
+
470
+ (defun hbdata:to-entry-in-file (key-src &optional directory create )
447
471
" Move point to end of line in but data buffer matching KEY-SRC.
448
472
Use hbdata file in KEY-SRC's directory, or optional DIRECTORY or if nil, use
449
473
`default-directory' .
@@ -452,44 +476,39 @@ beginning of the hbdata file (which is created if necessary).
452
476
Return non-nil if KEY-SRC is found or created, else nil."
453
477
(let (rtn
454
478
ln-dir)
455
- ; ; Drafts of mail messages now have a buffer-file-name since they
456
- ; ; are temporarily saved to a file until sent. But but-data still
457
- ; ; should be stored in the mail buffer itself, so check explicitly
458
- ; ; whether is a mail composition buffer in such cases.
459
- (if (or (hmail:mode-is-p)
460
- (and (get-buffer key-src)
461
- (set-buffer key-src)
462
- (not buffer-file-name)))
463
- ; ; Button buffer has no file attached
464
- (progn (if (hmail:hbdata-to-p) ; ; Might change the buffer
465
- (setq buffer-read-only nil )
466
- (when create
467
- (setq buffer-read-only nil )
468
- (insert " \n " hmail:hbdata-sep " \n " )))
469
- (backward-char 1 )
470
- (setq rtn t ))
471
- (setq directory (or (file-name-directory key-src) directory))
472
- (let ((ln-file) (link-p key-src))
473
- (while (setq link-p (file-symlink-p link-p))
474
- (setq ln-file link-p))
475
- (if ln-file
476
- (setq ln-dir (file-name-directory ln-file)
477
- key-src (file-name-nondirectory ln-file))
478
- (setq key-src (file-name-nondirectory key-src))))
479
- (when (or (hbdata:to-hbdata-buffer directory create)
480
- (and ln-dir (hbdata:to-hbdata-buffer ln-dir nil )
481
- (setq create nil
482
- directory ln-dir)))
483
- (goto-char 1 )
484
- (cond ((search-forward (concat " \^ L\n\" " key-src " \" " )
485
- nil t )
486
- (setq rtn t ))
487
- (create
488
- (setq rtn t )
489
- (insert " \^ L\n\" " key-src " \"\n " )
490
- (backward-char 1 )))))
479
+ (setq directory (or (file-name-directory key-src) directory))
480
+ (let ((ln-file) (link-p key-src))
481
+ (while (setq link-p (file-symlink-p link-p))
482
+ (setq ln-file link-p))
483
+ (if ln-file
484
+ (setq ln-dir (file-name-directory ln-file)
485
+ key-src (file-name-nondirectory ln-file))
486
+ (setq key-src (file-name-nondirectory key-src))))
487
+ (when (or (hbdata:to-hbdata-buffer directory create)
488
+ (and ln-dir (hbdata:to-hbdata-buffer ln-dir nil )
489
+ (setq create nil
490
+ directory ln-dir)))
491
+ (goto-char 1 )
492
+ (cond ((search-forward (concat " \^ L\n\" " key-src " \" " )
493
+ nil t )
494
+ (setq rtn t ))
495
+ (create
496
+ (setq rtn t )
497
+ (insert " \^ L\n\" " key-src " \"\n " )
498
+ (backward-char 1 ))))
491
499
rtn))
492
500
501
+ (defun hbdata:to-entry-buf (key-src &optional directory create )
502
+ " Move point to end of line in but data buffer matching KEY-SRC.
503
+ Use hbdata file in KEY-SRC's directory, or optional DIRECTORY or if nil, use
504
+ `default-directory' .
505
+ With optional CREATE, if no such line exists, insert a new file entry at the
506
+ beginning of the hbdata file (which is created if necessary).
507
+ Return non-nil if KEY-SRC is found or created, else nil."
508
+ (if (hbdata:is-but-data-stored-in-buffer key-src)
509
+ (hbdata:to-entry-in-buffer create)
510
+ (hbdata:to-entry-in-file key-src directory create)))
511
+
493
512
(defun hbdata:to-hbdata-buffer (dir &optional create )
494
513
" Read in the file containing DIR's button data, if any, and return buffer.
495
514
If it does not exist and optional CREATE is non-nil, create a new
0 commit comments