[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/lentic 26b2d4c8b5 215/333: Adds commands for creating n
From: |
ELPA Syncer |
Subject: |
[elpa] externals/lentic 26b2d4c8b5 215/333: Adds commands for creating new views. |
Date: |
Tue, 27 Feb 2024 13:00:36 -0500 (EST) |
branch: externals/lentic
commit 26b2d4c8b56c61ee7d30ce77fed229131fa58855
Author: Phillip Lord <phillip.lord@newcastle.ac.uk>
Commit: Phillip Lord <phillip.lord@newcastle.ac.uk>
Adds commands for creating new views.
These are the views in addition to the views given in lentic-init.
---
README.md | 4 +-
lentic-mode.el | 30 ++++++++++++---
lentic.el | 116 ++++++++++++++++++++++++++++++++++++++-------------------
3 files changed, 106 insertions(+), 44 deletions(-)
diff --git a/README.md b/README.md
index 640ea82397..64a8ac57cb 100644
--- a/README.md
+++ b/README.md
@@ -29,7 +29,8 @@ This buffer introduces multiple lentic buffers. This is
important because
lentic has more than one use -- both for maintaining two syntactic views (for
example for literate programming) and for maintaining two identical persistent
views (for example, for editing a file in two places at once). It's now
-possible to do both of these at the same time.
+possible to do both of these at the same time. Specific support has been added
+for views in lentic-mode.
This necessitates a change to the return value of lentic-clone to enable the
percolation of changes between several buffers. In this default usage of two
@@ -38,6 +39,7 @@ lentic buffers this will have no effect.
#### New Features
- Multiple lentic buffers are now possible.
+- Features to create new views.
#### Breaking Changes
diff --git a/lentic-mode.el b/lentic-mode.el
index 2473507004..6c769a6a65 100644
--- a/lentic-mode.el
+++ b/lentic-mode.el
@@ -118,8 +118,8 @@ A and B are the buffers."
window-b a))))
;;;###autoload
-(defun lentic-mode-create-in-selected-window ()
- "Create a lentic buffer and move it to the current window."
+(defun lentic-mode-move-in-selected-window ()
+ "Move the lentic buffer into the current window, creating if necessary."
(interactive)
(let ((before-window-start
(window-start (get-buffer-window)))
@@ -136,7 +136,7 @@ A and B are the buffers."
;;;###autoload
(defun lentic-mode-split-window-below ()
- "Create a lentic buffer in a new window below."
+ "Move lentic buffer to the window below, creating if needed."
(interactive)
(set-window-buffer
(split-window-below)
@@ -144,11 +144,28 @@ A and B are the buffers."
;;;###autoload
(defun lentic-mode-split-window-right ()
- "Create a lentic buffer in a new window right."
+ "Move lentic buffer to the window right, creating if needed."
(interactive)
(set-window-buffer
(split-window-right)
(car (lentic-init-all-create))))
+
+(defun lentic-mode-create-new-view ()
+ (let* ((conf (lentic-default-init))
+ (_ (oset conf
+ :sync-point nil))
+ (that (lentic-create conf)))
+ (setq lentic-config
+ (cons conf lentic-config))
+ that))
+
+;;;###autoload
+(defun lentic-mode-create-new-view-in-selected-window ()
+ (interactive)
+ (set-window-buffer
+ (selected-window)
+ (lentic-mode-create-new-view)))
+
;; #+end_src
;; ** Minor Mode
@@ -182,6 +199,9 @@ A and B are the buffers."
(define-key lentic-mode-map
(kbd "C-c ,c") 'lentic-mode-create-in-selected-window)
+(define-key lentic-mode-map
+ (kbd "C-c ,v") 'lentic-mode-create-new-view-in-selected-window)
+
(defcustom lentic-mode-line-lighter "Lentic"
"Default mode lighter for lentic"
:group 'lentic
@@ -226,7 +246,7 @@ A and B are the buffers."
(easy-menu-change
'("Edit")
"Lentic"
- '(["Create Here" lentic-mode-create-in-selected-window
+ '(["Move Here" lentic-mode-move-in-selected-window
:active (not lentic-config)]
["Split Below" lentic-mode-split-window-below
:active (not lentic-config)]
diff --git a/lentic.el b/lentic.el
index 63e2483eb6..3cf698825f 100644
--- a/lentic.el
+++ b/lentic.el
@@ -161,7 +161,6 @@
;; write new configurations for, and is still reasonable performant to 3-400
;; line buffers.
-
;;; Code:
;; ** State
@@ -253,7 +252,7 @@ by which linking happens.")
(defgeneric lentic-create (conf))
(defgeneric lentic-convert (conf location))
(defgeneric lentic-invert (conf that-buffer))
-
+(defgeneric lentic-coexist? (this-conf that-conf))
(defmethod lentic-this ((conf lentic-configuration))
(oref conf :this-buffer))
@@ -362,14 +361,25 @@ created."
(list (lentic-invert conf))))
that-buffer))
+(defmethod lentic-coexist? ((this-conf lentic-default-configuration)
+ that-conf)
+ "For this configuration, return true if that-conf can be allowed to coexist,
+or false if not."
+ (not
+ (and (oref this-conf :lentic-file)
+ (oref that-conf :lentic-file)
+ (f-equal? (oref this-conf :lentic-file)
+ (oref that-conf :lentic-file)))))
+
(defmethod lentic-invert ((conf lentic-default-configuration))
- (lentic-default-configuration
- (lentic-config-name (lentic-that conf))
+ (clone
+ conf
:this-buffer (lentic-that conf)
- :that-buffer (lentic-this conf)))
+ :that-buffer (lentic-this conf)
+ :sync-point (oref conf :sync-point)))
(defmethod lentic-convert ((conf lentic-default-configuration)
- location)
+ location)
"For this configuration, convert location to an equivalent location in
the lentic."
location)
@@ -496,7 +506,7 @@ buffer."
(let ((that
(lentic-that conf)))
(when (and (not (-contains? seen-buffer that))
- (buffer-live-p that))
+ (buffer-live-p that))
(funcall fn that)
(lentic-each that fn seen-buffer))))
lentic-config)))
@@ -574,17 +584,32 @@ repeated errors.")
(defun lentic-after-save-hook ()
(unless lentic-emergency
- (lentic-each
- (current-buffer)
- (lambda (buffer)
- (with-current-buffer
- buffer
- (save-buffer))))))
+ (condition-case err
+ (lentic-after-save-hook-1)
+ (error
+ (lentic-hook-fail err "after-save-hook")))))
+
+(defun lentic-after-save-hook-1 ()
+ (lentic-each
+ (current-buffer)
+ (lambda (buffer)
+ (with-current-buffer
+ buffer
+ (save-buffer)))))
(defvar lentic-kill-retain nil
"If non-nil retain files even if requested to delete on exit.")
(defun lentic-kill-buffer-hook ()
+ (unless lentic-emergency
+ (condition-case err
+ (lentic-kill-buffer-hook-1)
+ (error
+ (lentic-hook-fail err "kill-buffer-hook")))))
+
+(defvar lentic--killing-p nil)
+
+(defun lentic-kill-buffer-hook-1 ()
(lentic-when-lentic
(when
(and
@@ -601,16 +626,26 @@ repeated errors.")
(delete-file (buffer-file-name)))
;; if we were the creator buffer, blitz the lentics (which causes their
;; files to delete also).
- (when
- (--any?
- (oref it :creator)
- lentic-config)
- (lentic-each
- (current-buffer)
- (lambda (buffer)
- (kill-buffer buffer))))))
+ (let ((lentic-killing-p t))
+ (when
+ (and
+ (not lentic-killing-p)
+ (--any?
+ (oref it :creator)
+ lentic-config))
+ (lentic-each
+ (current-buffer)
+ (lambda (buffer)
+ (kill-buffer buffer)))))))
(defun lentic-kill-emacs-hook ()
+ (unless lentic-emergency
+ (condition-case err
+ (lentic-kill-emacs-hook-1)
+ (error
+ (lentic-hook-fail err "kill-emacs-hook")))))
+
+(defun lentic-kill-emacs-hook-1 ()
(-map
(lambda (buffer)
(lentic-with-lentic-buffer
@@ -670,31 +705,34 @@ ERR is the error. HOOK is the hook type."
(defun lentic-ensure-init ()
"Ensure that the `lentic-init' has been run."
- (unless (and lentic-config
- (-any?
- (lambda (conf)
- (and
- (slot-boundp conf :that-buffer)
- (buffer-live-p
- (lentic-that conf))))
- lentic-config))
- (setq lentic-config
+ (setq lentic-config
+ ;; and attach to lentic-config
+ (-concat
+ lentic-config
+ ;; return only those that can co-exist
+ (-filter
+ (lambda (this-conf)
+ (-all?
+ (lambda (that-conf)
+ (lentic-coexist? this-conf that-conf))
+ lentic-config))
(-map
(lambda (init)
+ ;; instantiate a new conf object (but do not create the buffer)
(funcall init))
- (-list lentic-init)))))
-
-(defun lentic-init-create (conf)
- "Create the lentic for CONF."
- (lentic-ensure-init)
- (lentic-create conf))
+ (-list lentic-init))))))
(defun lentic-init-all-create ()
"Create all lentics fo the current buffer."
(lentic-ensure-init)
(-map
(lambda (conf)
- (lentic-create conf))
+ (if (and
+ (slot-boundp conf :that-buffer)
+ (buffer-live-p
+ (lentic-that conf)))
+ (lentic-that conf)
+ (lentic-create conf)))
(-list lentic-config)))
(defvar lentic-emergency-last-change nil)
@@ -722,7 +760,9 @@ rest is currently just ignored."
(setq seen-buffer (cons buffer seen-buffer))
(-map
(lambda (config)
- (unless (-contains? seen-buffer (lentic-that config))
+ (unless
+ (or (-contains? seen-buffer (lentic-that config))
+ (not (buffer-live-p (lentic-that config))))
(let ((updates
(or
(lentic-update-contents config
- [elpa] externals/lentic 819ac479c4 188/333: Removed erroneous () in header., (continued)
- [elpa] externals/lentic 819ac479c4 188/333: Removed erroneous () in header., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic b4c95e69df 196/333: Cosmetic Change., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic a1799b72f7 197/333: Rot-13 added., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic f90bda3f74 204/333: Prepare for next iteration., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 5f8b9dbe0a 205/333: literate-haskell example., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic cafbf52329 206/333: Auto save files excluded!, ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 593cd7a7b5 203/333: v0.7 release., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 4e42c930d7 210/333: Default mode is now the same as the main buffer., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 94d7489962 208/333: lentic-doc now requires f.el, ELPA Syncer, 2024/02/27
- [elpa] externals/lentic aabb1c4593 212/333: Merge branch 'feature/multiple-lentic-buffers', ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 26b2d4c8b5 215/333: Adds commands for creating new views.,
ELPA Syncer <=
- [elpa] externals/lentic b6bbcc4e99 220/333: Force install on every test., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 2adfcc5493 225/333: Attempt to keep point static., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic ee88df4543 229/333: Add fall back if there is no visible lentic., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 4162e4e298 231/333: Delete lenticular.html on clean., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic f797675a52 228/333: Further attempts to make test stateless., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 97e1440857 230/333: Mode line update performance speed up., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 19c58b8bf7 238/333: Completion for all lentic packages., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 90c36b492a 233/333: Correcting typos, ELPA Syncer, 2024/02/27
- [elpa] externals/lentic a3b6da6235 235/333: lentic-doc now generic for any package., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 15ff7a4d72 234/333: Checkdoc ran., ELPA Syncer, 2024/02/27