From: rearman Date: Wed, 6 Dec 2023 14:41:22 +0000 (-0500) Subject: Add acme-mouse.el, add another abbrev for org X-Git-Url: https://git.earman.xyz/?a=commitdiff_plain;h=974d5d6c0ca2f63df34a0ded90329956a9023d4c;p=emacsinit.git Add acme-mouse.el, add another abbrev for org --- diff --git a/abbrev_defs b/abbrev_defs index 996b0b7..eae7cfe 100644 --- a/abbrev_defs +++ b/abbrev_defs @@ -1,5 +1,6 @@ ;;-*-coding: utf-8;-*- (define-abbrev-table 'org-mode-abbrev-table - '(("selisp" "" skel-org-block-elisp :count 1) - ("sfac" "" skel-facility-properties :count 2) - ("sper" "" skel-person-properties :count 1))) + '(("selisp" "" skel-org-block-elisp) + ("sfac" "" skel-facility-properties) + ("sper" "" skel-person-properties) + ("swo" "" skel-workorder-properties))) diff --git a/acme-mouse.el b/acme-mouse.el new file mode 100644 index 0000000..23c1bf8 --- /dev/null +++ b/acme-mouse.el @@ -0,0 +1,208 @@ +;;; acme-mouse.el --- mouse-button chording + +;; Author: Alex Kritikos (my gmail.com username is alex.kritikos) +;; Copyright (C) 2009, Alex Kritikos, see section 'Terms'. + +;; Description: + +;; The Acme editor from Plan 9 has very nice two-button mouse chords +;; for cut, copy and paste, and a handy right-click "find" +;; function. Please see http://swtch.com/plan9port/man/man1/acme.html +;; and http://plan9.bell-labs.com/sys/doc/acme/acme.pdf for more +;; information on how the chords are used. This package aims to work +;; the same as much as makes sense for Emacs. + +;; Terms: + +;; This program is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 2 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;; Todo: + +;; Allow drag-highlighting with the right button (secondary selection?) + +;; Make this a proper minor mode without clobbering keymaps and global +;; settings + +;; Clicks in the gutter/margin don't seem to work right + +;; Sometimes the region is active after the command, when we don't +;; want it to be. Leads to large highlighted regions. Goes away after +;; a click. + +;; Acme mouse chording doesn't make much sense without +;; delete-selection mode +(delete-selection-mode t) +;; Acme doesn't set the selection until you explicitly copy +(setq mouse-drag-copy-region nil) +(setq acme-mouse-state 'none) +(setq acme-last-command 'none) + +;; default: mouse-drag-region +(global-set-key [(down-mouse-1)] 'acme-down-mouse-1) + +;; default: mouse-set-point +(global-set-key [(mouse-1)] 'acme-mouse-1) + +;; default: mouse-set-region +(global-set-key [(drag-mouse-1)] 'acme-drag-mouse-1) +(global-set-key [(double-drag-mouse-1)] 'acme-double-mouse-1) +(global-set-key [(triple-drag-mouse-1)] 'acme-double-mouse-1) + +(global-set-key [(double-mouse-1)] 'acme-double-mouse-1) +(global-set-key [(triple-mouse-1)] 'acme-double-mouse-1) + +;; default: none +(global-set-key [(down-mouse-2)] 'acme-down-mouse-2) + +;; default: mouse-yank-at-click +(global-set-key [(mouse-2)] 'acme-mouse-2) + +;; default: none +(global-set-key [(down-mouse-3)] 'acme-down-mouse-3) + +;; default: mouse-save-then-kill +(global-set-key [(mouse-3)] 'acme-mouse-3) + +;; everything starts with this function, so set state accordingly +(defun acme-down-mouse-1 (click) + (interactive "e") + ;; which buttons are currently pressed? + (setq acme-mouse-state 'left) + (setq acme-last-command 'none) + (mouse-set-mark click) + ;; pass to regular click handler + (mouse-drag-region click)) + +;; called if mouse doesn't move between button down and up +(defun acme-mouse-1 (click) + (interactive "e") + (setq acme-mouse-state 'none) + (setq deactivate-mark nil) + (if (eq acme-last-command 'none) + (mouse-set-point click)) + (setq transient-mark-mode (cons 'only t)) + (setq acme-last-command 'none)) + +(defun acme-double-mouse-1 (click) + (interactive "e") + (setq acme-mouse-state 'none) + (setq deactivate-mark nil) + ;; if we were just selecting, and not chording, pass to the regular click handler + (if (eq acme-last-command 'none) + (progn (mouse-set-point click) + (acme-select-region))) + (setq transient-mark-mode (cons 'only t)) + (setq acme-last-command 'none)) + +;; called if mouse moves between button down and up +(defun acme-drag-mouse-1 (click) + (interactive "e") + (if (eq acme-last-command 'none) + (mouse-set-region click)) + (acme-mouse-1 click)) + +(defun acme-select-region () + (let ((range (mouse-start-end (mark) (point) mouse-selection-click-count))) + (setq acme-start (car range)) + (setq acme-end (nth 1 range)) + (set-mark acme-start) + (goto-char acme-end))) + +(defun acme-down-mouse-2 (click) + (interactive "e") + (if (eq acme-mouse-state 'left) + (progn (setq acme-mouse-state 'left-middle) + (if (eq acme-last-command 'paste) + (undo) + (mouse-set-point click) + (acme-select-region) + (kill-region (mark) (point))) + (setq acme-last-command 'cut)) + (popup-menu (mouse-menu-major-mode-map) click))) + +(defun acme-mouse-2 () + (interactive) + (if (eq acme-mouse-state 'left-middle) + (setq acme-mouse-state 'left))) + +(defun acme-down-mouse-3 (click arg) + (interactive "e\nP") + (if (eq acme-mouse-state 'left) + (progn + (setq acme-mouse-state 'left-right) + (cl-case acme-last-command + (none (mouse-set-point click) + (acme-select-region) + (delete-region (mark) (point)) + (yank arg)) + (cut (undo) + (set-mark acme-start) + (goto-char acme-end))) + (setq acme-last-command 'paste) + (setq deactivate-mark nil) + (activate-mark)))) + +(defun acme-mouse-3 (click) + (interactive "e") + (if (eq acme-mouse-state 'left-right) + (setq acme-mouse-state 'left) + (acme-search click))) + +;; Search - modified from Dan McCarthy's acme-search.el + +(defun header-line-active-p () + (not (null header-line-format))) + +(defun move-mouse-to-point () + "Move the mouse pointer to point in the current window." + (let* ((coords (posn-col-row (posn-at-point))) + (window-coords (window-inside-edges)) + (x (+ (car coords) (car window-coords) -1)) ;the fringe is 0 + (y (+ (cdr coords) (cadr window-coords) + (if (header-line-active-p) + -1 + 0)))) + (set-mouse-position (selected-frame) x y))) + +(defun acme-highlight-search (sym) + "Set the region to the current search result. Assume point is +at the end of the result." + (set-mark (point)) + (search-backward sym nil t) + (exchange-point-and-mark)) + +(defun acme-search (posn) + "Search forward for the symbol under mouse, moving mouse and point forward. +This is inspired by Rob Pike's Acme." + (let ((sym (if (region-active-p) + (buffer-substring (mark) (point)) + (mouse-set-point posn) + (thing-at-point 'filename)))) + (if (file-readable-p sym) + (special-display-popup-frame (find-file-noselect sym nil nil nil)) + (if (search-forward sym nil t) + (acme-highlight-search sym) + (let ((saved-point (point))) + (message "Wrapped search") + (goto-char (point-min)) + (if (search-forward sym nil t) + (acme-highlight-search sym) + (goto-char saved-point))))) + ;;Redisplay the screen if we search off the bottom of the window. + (unless (posn-at-point) + (universal-argument) + (recenter)) + (move-mouse-to-point))) + +(provide 'acme-mouse) diff --git a/init.org b/init.org index 4c2975b..b4d177a 100644 --- a/init.org +++ b/init.org @@ -240,7 +240,7 @@ I need to open binary files with their own editor. Disgusting. '(file)))) #+END_SRC -*** Org-transclusion +*** org-transclusion Awesome package - adds transclusions, don't know how similar to Xanadu it is, but sounds basically the same. #+BEGIN_SRC emacs-lisp @@ -250,6 +250,12 @@ Awesome package - adds transclusions, don't know how similar to Xanadu it is, bu ("C-c n t" . org-transclusion-mode))) #+END_SRC +*** acme-mouse +Not a package in the strict sense, just a .el file - pulled from [[https://github.com/akrito/acme-mouse/]] and modified to meet changes to the old =cl= package. +#+BEGIN_SRC emacs-lisp +(load (concat user-emacs-directory "acme-mouse.el")) +#+END_SRC + ** Non-Package customization This section has '/base/' emacs customization. All the general stuff. @@ -392,7 +398,7 @@ Make the paren "highlight" the same color as the background, and add underline. #+BEGIN_SRC emacs-lisp (set-face-attribute 'show-paren-match nil - :background nil + :background 'unspecified :underline t) #+END_SRC @@ -562,8 +568,8 @@ Tag filtering Capture Templates per my proclivities. #+BEGIN_SRC emacs-lisp (setq org-capture-templates '(("n" "Note" entry (file org-default-notes-file) "* %u %?") - ("t" "TODO" entry (file org-default-notes-file) "* TODO %? \n%U\n") - ("a" "Appointment" entry (file+olp+datetree org-journal-file) "* APPT %? \nSCHEDULED: %t" :time-prompt t) + ("t" "TODO" entry (file org-default-notes-file) "* TODO %?\n%U\n") + ("a" "Appointment" entry (file+olp+datetree org-journal-file) "* APPT %?\nSCHEDULED: %t" :time-prompt t) ("j" "Journal" entry (file+olp+datetree org-journal-file) "* %?\n%U\n"))) #+END_SRC @@ -604,13 +610,23 @@ Person properties block "#+FILETAGS: Company Position\n") #+END_SRC +Workorder properties block +#+BEGIN_SRC emacs-lisp +(define-skeleton skel-workorder-properties + "Insert the org title and filetags for a workorder" + "" + "#+TITLE: Workorder ###\n" + "#+FILETAGS: workorder cust-facil topics\n") +#+END_SRC + Bind the snippets (in the =abbrev-file-name= file) #+BEGIN_SRC emacs-lisp :tangle ./abbrev_defs ;;-*-coding: utf-8;-*- (define-abbrev-table 'org-mode-abbrev-table - '(("selisp" "" skel-org-block-elisp :count 1) - ("sfac" "" skel-facility-properties :count 2) - ("sper" "" skel-person-properties :count 1))) + '(("selisp" "" skel-org-block-elisp) + ("sfac" "" skel-facility-properties) + ("sper" "" skel-person-properties) + ("swo" "" skel-workorder-properties))) #+END_SRC *** Auto-archive