[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/lentic 9194eac956 049/333: Linked-buffer minor mode add
From: |
ELPA Syncer |
Subject: |
[elpa] externals/lentic 9194eac956 049/333: Linked-buffer minor mode added. |
Date: |
Tue, 27 Feb 2024 13:00:00 -0500 (EST) |
branch: externals/lentic
commit 9194eac9569ae091990a3bb807ba5c7e803ec715
Author: Phillip Lord <phillip.lord@newcastle.ac.uk>
Commit: Phillip Lord <phillip.lord@newcastle.ac.uk>
Linked-buffer minor mode added.
---
linked-buffer-asciidoc.el | 14 ++++-
linked-buffer-latex-code.el | 6 ++
linked-buffer.el | 133 +++++++++++++++++++++++++++++++++++++++++---
3 files changed, 144 insertions(+), 9 deletions(-)
diff --git a/linked-buffer-asciidoc.el b/linked-buffer-asciidoc.el
index 1b4097a7b3..2885a244fe 100644
--- a/linked-buffer-asciidoc.el
+++ b/linked-buffer-asciidoc.el
@@ -44,6 +44,9 @@
(setq linked-buffer-config
(linked-buffer-asciidoc-commented-new)))
+(add-to-list 'linked-buffer-init-functions
+ 'linked-buffer-clojure-asciidoc-init)
+
(defun linked-buffer-asciidoc-uncommented-new ()
(linked-buffer-uncommented-asciidoc-configuration
"lb-uncommented-clojure-asciidoc"
@@ -58,14 +61,21 @@
(setq linked-buffer-config
(linked-buffer-asciidoc-uncommented-new)))
+(add-to-list 'linked-buffer-init-functions
+ 'linked-buffer-asciidoc-clojure-init)
+
(defclass linked-buffer-commented-asciidoc-configuration
(linked-buffer-commented-block-configuration)
- ()
+ ((srctags :initarg :srctags
+ :documentation "Language tags in source block"
+ :initform '("clojure" "lisp")))
"Linked buffer config for asciidoc and other code.")
(defclass linked-buffer-uncommented-asciidoc-configuration
(linked-buffer-uncommented-block-configuration)
- ()
+ ((srctags :initarg :srctags
+ :documentation "Language tags in source block"
+ :initform '("clojure" "lisp")))
"Linked buffer config for asciidoc and other code")
diff --git a/linked-buffer-latex-code.el b/linked-buffer-latex-code.el
index de6075a8ee..4c585a7d0f 100644
--- a/linked-buffer-latex-code.el
+++ b/linked-buffer-latex-code.el
@@ -55,9 +55,15 @@
:comment-stop "\\\\begin{code}"))
(error "Can only use linked-buffer-clojure-latex-init in a .clj buffer")))
+(add-to-list 'linked-buffer-init-functions
+ 'linked-buffer-clojure-latex-init)
+
(defun linked-buffer-clojure-latex-delayed-init ()
(linked-buffer-delayed-init 'linked-buffer-clojure-latex-init))
+(add-to-list 'linked-buffer-init-functions
+ 'linked-buffer-clojure-latex-delayed-init)
+
(provide 'linked-buffer-latex-code)
;;; linked-buffer-latex-code ends here
diff --git a/linked-buffer.el b/linked-buffer.el
index af0b522e4b..b359b75d71 100644
--- a/linked-buffer.el
+++ b/linked-buffer.el
@@ -113,6 +113,10 @@ of mode in the current buffer.")
(make-variable-buffer-local 'linked-buffer-config)
(put 'linked-buffer-config 'permanent-local t)
+(defvar linked-buffer-init-functions nil
+ "A list of all functions that can be used as linked-buffer-init
+ functions.")
+
(defun linked-buffer-config-name (buffer)
"Given BUFFER, return a name for the configuration object."
(format "linked: %s" buffer))
@@ -227,6 +231,9 @@ See `linked-buffer-init' for details."
(linked-buffer-config-name (current-buffer))
:this-buffer (current-buffer))))
+(add-to-list 'linked-buffer-init-functions
+ 'linked-buffer-default-init)
+
;;
;; End the configuration section.
;;
@@ -306,23 +313,51 @@ ERR is the error. HOOK is the hook type."
(princ (error-message-string err)))
(select-window (get-buffer-window "*linked-buffer-fail*")))
-(defun linked-buffer-swap-windows ()
- "Swaps buffer with linked-buffer in current window."
+(defun linked-buffer-move-linked-window ()
+ "Move the linked-buffer into the current window.
+If the linked-buffer is currently being displayed in another
+window, then the current-buffer will be moved into that window.
+See also `linked-buffer-swap-buffer-windows'."
+ (interactive)
+ (let ((before-window-start
+ (window-start (get-buffer-window)))
+ (before-window-point
+ (point)))
+ (linked-buffer-swap-buffer-windows
+ (current-buffer)
+ (linked-buffer-that linked-buffer-config))
+ (set-window-start
+ (selected-window)
+ before-window-start)
+ (goto-char before-window-point)))
+
+(defun linked-buffer-swap-linked-window ()
+ "Swap the window of the buffer and linked-buffer.
+If both are current displayed, swap the windows they
+are displayed in, which keeping current buffer.
+See also `linked-buffer-move-linked-window'."
(interactive)
(linked-buffer-swap-buffer-windows
(current-buffer)
(linked-buffer-that linked-buffer-config))
- (select-window (get-buffer-window (current-buffer))))
+ (when (window-live-p
+ (get-buffer-window
+ (current-buffer)))
+ (select-window
+ (get-buffer-window
+ (current-buffer)))))
(defun linked-buffer-swap-buffer-windows (a b)
"Swaps the window that two buffers are displayed in.
A and B are the buffers."
(let ((window-a (get-buffer-window a))
(window-b (get-buffer-window b)))
- (set-window-buffer
- window-a b)
- (set-window-buffer
- window-b a)))
+ (when window-a
+ (set-window-buffer
+ window-a b))
+ (when window-b
+ (set-window-buffer
+ window-b a))))
(defun linked-buffer-ensure-init ()
"Ensure that the `linked-buffer-init' has been run."
@@ -338,6 +373,22 @@ A and B are the buffers."
(linked-buffer-ensure-init)
(linked-buffer-create linked-buffer-config))
+(defun linked-buffer-create-in-selected-window ()
+ "Create a linked buffer and move it to the current window."
+ (interactive)
+ (let ((before-window-start
+ (window-start (get-buffer-window)))
+ (before-window-point
+ (point)))
+ (linked-buffer-ensure-init)
+ (set-window-buffer
+ (selected-window)
+ (linked-buffer-create linked-buffer-config))
+ (set-window-start
+ (selected-window)
+ before-window-start)
+ (goto-char before-window-point)))
+
(defun linked-buffer-split-window-below ()
"Create a linked buffer in a new window below."
(interactive)
@@ -425,6 +476,74 @@ same top-left location. Update details depend on CONF."
(set-window-start window from-window-start))))
(get-buffer-window-list (linked-buffer-that conf)))))
+;;
+;; Minor mode
+;;
+
+(defvar linked-buffer-mode-map (make-sparse-keymap)
+ "Keymap for linked-buffer-minor-mode")
+
+(define-key linked-buffer-mode-map
+ (kbd "C-c ,s") 'linked-buffer-swap-linked-window)
+
+(define-key linked-buffer-mode-map
+ (kbd "C-c ,h") 'linked-buffer-move-linked-window)
+
+(define-minor-mode linked-buffer-mode
+ :lighter "lb"
+ :keymap linked-buffer-mode-map)
+
+(easy-menu-change
+ '("Edit")
+ "Linked"
+ '(["Create Here" linked-buffer-create-in-selected-window]
+ ["Split Below" linked-buffer-split-window-below]
+ ["Split Right" linked-buffer-split-window-right]
+ ["Move Here" linked-buffer-move-linked-window :active linked-buffer-config]
+ ["Swap" linked-buffer-swap-buffer-windows :active linked-buffer-config]))
+
+(defun linked-buffer-insert-file-local (init-function)
+ (interactive
+ (list (completing-read
+ "Linked-Buffer init function: "
+ (mapcar
+ 'symbol-name
+ linked-buffer-init-functions)
+ 'identity 'confirm)))
+ (save-excursion
+ (goto-char (point-max))
+ (let ((start (point)))
+ (insert
+ (format
+ "\nLocal Variables:\nlinked-buffer-init: %s\nEnd:\n" init-function))
+ (comment-region start (point)))))
+
+(defvar linked-buffer-start-mode-map (make-sparse-keymap))
+
+(define-key linked-buffer-start-mode-map
+ (kbd "C-c ,b") 'linked-buffer-split-window-below)
+
+(define-key linked-buffer-start-mode-map
+ (kbd "C-c ,r") 'linked-buffer-split-window-right)
+
+(define-key linked-buffer-start-mode-map
+ (kbd "C-c ,f") 'linked-buffer-insert-file-local)
+
+(define-key linked-buffer-start-mode-map
+ (kbd "C-c ,c") 'linked-buffer-create-in-selected-window)
+
+
+(define-minor-mode linked-buffer-start-mode
+ :lighter ""
+ :keymap linked-buffer-start-mode-map)
+
+(define-globalized-minor-mode global-linked-buffer-start-mode
+ linked-buffer-start-mode
+ linked-buffer-start-on)
+
+(defun linked-buffer-start-on ()
+ (linked-buffer-start-mode 1))
+
;;
;; Test functions!
;;
- [elpa] externals/lentic fe3efb4ef6 040/333: evm/cask install, (continued)
- [elpa] externals/lentic fe3efb4ef6 040/333: evm/cask install, ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 3528da0a11 032/333: linked-buffer-asciidoc support., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 45d07d6416 034/333: Documentation cleanup., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 3405c13254 033/333: Change fundamental-mode to normal-mode, ELPA Syncer, 2024/02/27
- [elpa] externals/lentic de2450d3e4 043/333: Removed condition-case-no-debug, ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 049330626e 044/333: Version number changes., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 661cb19252 028/333: Changes to test setup., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic e7f4d91f88 047/333: Support file-locals in linked-buffer., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic cf5f4a3b72 046/333: pabbrev handling was broken., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 1a181b7502 054/333: m-buffer not need in cask, as declared in headers., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 9194eac956 049/333: Linked-buffer minor mode added.,
ELPA Syncer <=
- [elpa] externals/lentic 96466482ca 052/333: Cosmetic and documentation changes., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 1bf2b709e0 063/333: Use three arguments for m-buffer-replace-match, ELPA Syncer, 2024/02/27
- [elpa] externals/lentic b6b9293635 061/333: Added file local functions., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic bbc60fc6d4 056/333: Support el-to-org., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic a2d2e6dfcd 065/333: Literate documentation for linked-buffer-org., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic cd2ee3b53c 068/333: Point syncing is now an option., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic fead80b26a 078/333: First nearly working version., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 9913c47912 081/333: Convert start point before changes., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 0740c92916 084/333: Pabbrev support dropped., ELPA Syncer, 2024/02/27
- [elpa] externals/lentic 783951ac3e 072/333: Use case insensitive regexp., ELPA Syncer, 2024/02/27