[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/objed f8af251 080/216: General cleanup
From: |
Stefan Monnier |
Subject: |
[elpa] externals/objed f8af251 080/216: General cleanup |
Date: |
Tue, 8 Jan 2019 12:29:16 -0500 (EST) |
branch: externals/objed
commit f8af251ee26b5106e330d17e5b3e76d6c70f72b3
Author: Clemera <address@hidden>
Commit: Clemera <address@hidden>
General cleanup
---
objed-objects.el | 325 +++++++++++++++++++++++++++----------------------------
objed.el | 209 ++++++++++++++++++-----------------
2 files changed, 273 insertions(+), 261 deletions(-)
diff --git a/objed-objects.el b/objed-objects.el
index 3120b27..cc4a331 100644
--- a/objed-objects.el
+++ b/objed-objects.el
@@ -40,12 +40,22 @@
(declare-function outline-next-visible-heading "ext:outline")
(declare-function outline-previous-visible-heading "ext:outline")
+(declare-function objed--object-dispatch "ext:objed")
+(declare-function objed-current-or-next-context "ext:objed")
+(declare-function objed-current-or-previous-context "ext:objed")
+(declare-function objed--install-advices "ext:objed")
+(declare-function objed--get-current-state "ext:objed")
+
;; dyn bindings
(defvar avy-action nil)
(defvar avy-all-windows nil)
;; * Macros
+(defvar objed--object nil
+ "The symbol of the current object.")
+
+
(defmacro objed-define-object (key name &rest args)
"Declare a text object for `objed'.
@@ -198,42 +208,10 @@ is not skipped before search for the next one via
:try-next."
,@body))
-(defun objed--object-dispatch (name)
- "Dispatch according to object NAME.
-
-Uses `objed--dispatch-alist' and defaults to
-update to given object."
- (let* ((cmd (key-binding
- (vector ;; (aref (this-command-keys-vector) 0)
- last-command-event)))
- (binding (assq cmd objed--dispatch-alist)))
- (cond (binding
- (funcall (cdr binding) name))
- (t
- ;; object called as command via M-x
- (when (not objed--buffer)
- (objed--init name))
- ;; TODO: do something useful if called twice?
- ;; (eq name objed--object)
- (when (objed--switch-to name)
- (goto-char (objed--beg)))))))
-
-(defun objed--inside-object-p (obj)
- "Return non-nil if point point inside object OBJ."
- (let* ((objed--object obj)
- (objed--obj-state 'whole)
- (obj (if (symbolp obj)
- (objed--get)
- obj)))
- (when (and obj (not (objed--distant-p obj)))
- obj)))
-
-
;; * Global vars saving object information
;; TODO: use defstruct object instead
-(defvar objed--object nil
- "The symbol of the current object.")
+
(defvar objed--current-obj nil
"The current object position data.
@@ -252,9 +230,18 @@ Either the symbol `whole' or `inner'.")
(defvar objed--marked-ovs nil
"List of overlays of marked objects.")
+;; * Get object positions
+(defun objed--inside-object-p (obj)
+ "Return non-nil if point point inside object OBJ."
+ (let* ((objed--object obj)
+ (objed--obj-state 'whole)
+ (obj (if (symbolp obj)
+ (objed--get)
+ obj)))
+ (when (and obj (not (objed--distant-p obj)))
+ obj)))
-;; * Get object positions
(defun objed--beg (&optional obj)
"Get beginning position of object.
@@ -341,6 +328,13 @@ OBJ is the object to use and defaults to
`objed--current-obj'."
(posn (objed--alt obj)))
(cadr posn)))
+(defun objed--goto-char (pos)
+ "Move to position POS possibly skipping leading whitespace."
+ (goto-char
+ (if (eq objed--object 'char)
+ pos
+ (objed--skip-forward pos 'ws))))
+
(defun objed--collect-backward (pos min &optional ends)
"Collect object positions in backward direction.
@@ -624,6 +618,115 @@ from beginning of object FROM."
(objed--object :try-prev)
(objed--get t)))))
+
+;; * Object creation/manipulation
+
+
+(cl-defun objed-make-object (&key obounds beg end ibounds ibeg iend)
+ "Helper to create internal used object format from positions.
+
+Positions of the whole object can be provided by BEG, END or a
+cons cell OBOUNDS.
+
+The positions of the inner part can be provided by IBEG, IEND or
+a cons cell IBOUNDS. If inner positions are omitted
+`objed--inner-default' is used to determine them."
+ (cl-assert (and (not (and obounds beg end))
+ (not (and ibounds ibeg iend))))
+ (cond ((and (integer-or-marker-p beg)
+ (integer-or-marker-p end)
+ (integer-or-marker-p ibeg)
+ (integer-or-marker-p iend))
+ (list (list (objed--pos-or-marker beg)
+ (objed--pos-or-marker end))
+ (list (objed--pos-or-marker ibeg)
+ (objed--pos-or-marker iend))))
+ ((and (integer-or-marker-p beg)
+ (integer-or-marker-p end))
+ (cond ((consp ibounds)
+ (list (list (objed--pos-or-marker beg)
+ (objed--pos-or-marker end))
+ (list (objed--pos-or-marker (car ibounds))
+ (objed--pos-or-marker (cdr ibounds)))))
+ ((or (functionp ibeg)
+ (functionp iend))
+ (list (list (objed--pos-or-marker beg)
+ (objed--pos-or-marker end))
+ (list (objed--pos-or-marker
+ (or (and (functionp ibeg)
+ (funcall ibeg beg))
+ ibeg))
+ (objed--pos-or-marker
+ (or (and (functionp iend)
+ (funcall iend end))
+ iend)))))
+ (t
+ (list (list (objed--pos-or-marker beg)
+ (objed--pos-or-marker end))
+ (objed--inner-default beg end)))))
+ ((consp obounds)
+ (cond ((consp ibounds)
+ (list (list (objed--pos-or-marker (car obounds))
+ (objed--pos-or-marker (cdr obounds)))
+ (list (objed--pos-or-marker (car ibounds))
+ (objed--pos-or-marker (cdr ibounds)))))
+ ((and (integer-or-marker-p ibeg)
+ (integer-or-marker-p iend))
+ (list (list (objed--pos-or-marker (car obounds))
+ (objed--pos-or-marker (cdr obounds)))
+ (list (objed--pos-or-marker ibeg)
+ (objed--pos-or-marker iend))))
+ ((or (functionp ibeg)
+ (functionp iend))
+ (list (list (objed--pos-or-marker (car obounds))
+ (objed--pos-or-marker (cdr obounds)))
+ (list (objed--pos-or-marker
+ (or (and (functionp ibeg)
+ (funcall ibeg beg))
+ ibeg))
+ (objed--pos-or-marker
+ (or (and (functionp iend)
+ (funcall iend end))
+ iend)))))
+ (t
+ (list (list (objed--pos-or-marker (car obounds))
+ (objed--pos-or-marker (cdr obounds)))
+ (objed--inner-default (car obounds) (cdr obounds))))))))
+
+
+(cl-defun objed--change-to (&key beg end ibeg iend)
+ "Change position data of current object.
+
+BEG: the beginning position
+END: the end position
+IBEG: the beginning position of the inner part
+IEND: the end position of the inner part"
+ (let ((beg (and beg (objed--pos-or-marker beg)))
+ (end (and end (objed--pos-or-marker end)))
+ (ibeg (and ibeg (objed--pos-or-marker ibeg)))
+ (iend (and iend (objed--pos-or-marker iend))))
+ (cond ((eq objed--obj-state 'whole)
+ (when beg
+ (setf (car (car objed--current-obj)) beg))
+ (when end
+ (setf (car (cdar objed--current-obj)) end))
+ (when ibeg
+ (setf (car (cadr objed--current-obj)) ibeg))
+ (when iend
+ (setf (cadr (cadr objed--current-obj)) iend)))
+ ((eq objed--obj-state 'inner)
+ (when ibeg
+ (setf (car (car objed--current-obj)) ibeg))
+ (when iend
+ (setf (car (cdar objed--current-obj)) iend))
+ (when beg
+ (setf (car (cadr objed--current-obj)) beg))
+ (when end
+ (setf (cadr (cadr objed--current-obj)) end)))
+ (t
+ (error "No valid `objed--obj-state'")))))
+
+
;; * Helpers to work with object format
@@ -700,15 +803,6 @@ according to `objed--obj-state'."
n))
-(defun objed--get-object-for-cmd (cmd)
- "Guess which object to use.
-
-CMD is the command for which object should be guessed. Returns
-the guessed object."
- (let ((c (cdr (assq cmd objed-cmd-alist))))
- (if (consp c) (objed--at-p c) c)))
-
-
(defun objed--in-p (c &optional inner)
"Return object name point is in.
@@ -731,16 +825,11 @@ C is a list of object names to test for."
(when (objed--object :atp cand)
(cl-return cand))))
-(defun objed--at-beg-p (c)
- "Return object name at point.
-
-C is a list of object names to test for."
- (let ((o (objed--at-p c)))
- (when o
- (objed--save-state
- (objed--switch-to o)
- (= (objed--beg) (point))))))
-
+(defun objed--indentation-position ()
+ "Get buffer position of indentation on current line."
+ (save-excursion
+ (back-to-indentation)
+ (point)))
(defun objed--apply (func &optional obj)
"Apply function FUNC on postions of object.
@@ -872,6 +961,11 @@ If OBJ is given use it instead `objed--current-obj'."
;; * Creating objects
+
+(defvar objed--block-p nil
+ "Block advices installed by `objed'.")
+
+
(defun objed-bounds-from-region-cmd (cmd)
"Return buffer positions of region created by command CMD.
@@ -903,109 +997,6 @@ positions."
(list (objed--pos-or-marker (point))
(objed--pos-or-marker (1+ (point)))))))
-(cl-defun objed-make-object (&key obounds beg end ibounds ibeg iend)
- "Helper to create internal used object format from positions.
-
-Positions of the whole object can be provided by BEG, END or a
-cons cell OBOUNDS.
-
-The positions of the inner part can be provided by IBEG, IEND or
-a cons cell IBOUNDS. If inner positions are omitted
-`objed--inner-default' is used to determine them."
- (cl-assert (and (not (and obounds beg end))
- (not (and ibounds ibeg iend))))
- (cond ((and (integer-or-marker-p beg)
- (integer-or-marker-p end)
- (integer-or-marker-p ibeg)
- (integer-or-marker-p iend))
- (list (list (objed--pos-or-marker beg)
- (objed--pos-or-marker end))
- (list (objed--pos-or-marker ibeg)
- (objed--pos-or-marker iend))))
- ((and (integer-or-marker-p beg)
- (integer-or-marker-p end))
- (cond ((consp ibounds)
- (list (list (objed--pos-or-marker beg)
- (objed--pos-or-marker end))
- (list (objed--pos-or-marker (car ibounds))
- (objed--pos-or-marker (cdr ibounds)))))
- ((or (functionp ibeg)
- (functionp iend))
- (list (list (objed--pos-or-marker beg)
- (objed--pos-or-marker end))
- (list (objed--pos-or-marker
- (or (and (functionp ibeg)
- (funcall ibeg beg))
- ibeg))
- (objed--pos-or-marker
- (or (and (functionp iend)
- (funcall iend end))
- iend)))))
- (t
- (list (list (objed--pos-or-marker beg)
- (objed--pos-or-marker end))
- (objed--inner-default beg end)))))
- ((consp obounds)
- (cond ((consp ibounds)
- (list (list (objed--pos-or-marker (car obounds))
- (objed--pos-or-marker (cdr obounds)))
- (list (objed--pos-or-marker (car ibounds))
- (objed--pos-or-marker (cdr ibounds)))))
- ((and (integer-or-marker-p ibeg)
- (integer-or-marker-p iend))
- (list (list (objed--pos-or-marker (car obounds))
- (objed--pos-or-marker (cdr obounds)))
- (list (objed--pos-or-marker ibeg)
- (objed--pos-or-marker iend))))
- ((or (functionp ibeg)
- (functionp iend))
- (list (list (objed--pos-or-marker (car obounds))
- (objed--pos-or-marker (cdr obounds)))
- (list (objed--pos-or-marker
- (or (and (functionp ibeg)
- (funcall ibeg beg))
- ibeg))
- (objed--pos-or-marker
- (or (and (functionp iend)
- (funcall iend end))
- iend)))))
- (t
- (list (list (objed--pos-or-marker (car obounds))
- (objed--pos-or-marker (cdr obounds)))
- (objed--inner-default (car obounds) (cdr obounds))))))))
-
-
-(cl-defun objed--change-to (&key beg end ibeg iend)
- "Change position data of current object.
-
-BEG: the beginning position
-END: the end position
-IBEG: the beginning position of the inner part
-IEND: the end position of the inner part"
- (let ((beg (and beg (objed--pos-or-marker beg)))
- (end (and end (objed--pos-or-marker end)))
- (ibeg (and ibeg (objed--pos-or-marker ibeg)))
- (iend (and iend (objed--pos-or-marker iend))))
- (cond ((eq objed--obj-state 'whole)
- (when beg
- (setf (car (car objed--current-obj)) beg))
- (when end
- (setf (car (cdar objed--current-obj)) end))
- (when ibeg
- (setf (car (cadr objed--current-obj)) ibeg))
- (when iend
- (setf (cadr (cadr objed--current-obj)) iend)))
- ((eq objed--obj-state 'inner)
- (when ibeg
- (setf (car (car objed--current-obj)) ibeg))
- (when iend
- (setf (car (cdar objed--current-obj)) iend))
- (when beg
- (setf (car (cadr objed--current-obj)) beg))
- (when end
- (setf (cadr (cadr objed--current-obj)) end)))
- (t
- (error "No valid `objed--obj-state'")))))
(defun objed--pos-or-marker (pos)
"Return marker or position POS.
@@ -1919,9 +1910,9 @@ non-nil the indentation block can contain empty lines."
(defun objed--get-face-range ()
"Return range of equal face before/after point."
(let ((point-face (objed--what-face))
- (backward-point (point)) ; last char when stop, including white space
+ (objed-cmd-alist (and (bound-and-true-p objed-cmd-alist)
+ objed-cmd-alist))
(backward-none-space-point (point)) ; last none white space char
- (forward-point (point)) ; last char when stop, including white space
(forward-none-space-point (point)) ; last none white space char
(start (point))
(end (point)))
@@ -1940,10 +1931,9 @@ non-nil the indentation block can contain empty lines."
(backward-char)
(let ((backward-point-face (objed--what-face)))
(if (= 32 (char-syntax (char-after)))
- (setq backward-point (point))
+ (ignore)
(if (equal point-face backward-point-face)
- (progn (setq backward-point (point))
- (setq backward-none-space-point (point)))
+ (setq backward-none-space-point (point))
(setq continue nil)))))))
;; check chars forward,
@@ -1954,10 +1944,9 @@ non-nil the indentation block can contain empty lines."
(forward-char)
(let ((forward-point-face (objed--what-face)))
(if (= 32 (char-syntax (char-after)))
- (setq forward-point (point))
+ (ignore)
(if (equal point-face forward-point-face)
- (progn (setq forward-point (point))
- (setq forward-none-space-point (point)))
+ (setq forward-none-space-point (point))
(setq continue nil)))))))
(progn (setq start backward-none-space-point)
@@ -1982,6 +1971,11 @@ non-nil the indentation block can contain empty lines."
(declare-function org-mark-element "ext:org")
+(declare-function python-nav-end-of-block "ext:python")
+(declare-function python-nav-beginning-of-block "ext:python")
+(declare-function python-nav-forward-block "ext:python")
+(declare-function python-nav-backward-block "ext:python")
+
(with-eval-after-load 'org
(objed-define-object nil section
:mode org-mode
@@ -2004,6 +1998,9 @@ non-nil the indentation block can contain empty lines."
(objed-make-object
:obounds (objed-bounds-from-region-cmd #'org-mark-element))))
+(defvar comint-prompt-regexp nil)
+(declare-function comint-next-prompt "ext:comint")
+(declare-function comint-previous-prompt "ext:comint")
(objed-define-object nil output
:atp
diff --git a/objed.el b/objed.el
index 369a384..26f0afc 100644
--- a/objed.el
+++ b/objed.el
@@ -228,71 +228,6 @@
(require 'objed-objects)
-;; * Objed Mode
-
-(defvar objed-mode-map
- (let ((map (make-sparse-keymap)))
- ;; because objed is a "big" addition to the interface overriding M-SPC
might
- ;; be ok
- (define-key map (kbd "M-SPC") 'objed-activate)
- ;;(define-key map (kbd "C-.") 'objed-activate)
- map)
- "Keymap for /function`objed-mode'.")
-
-;;;###autoload
-(define-minor-mode objed-mode
- "Enable objeds modal editing features after certain commands.
-
-With a prefix argument ARG, enable Objed mode if ARG is positive,
-and disable it otherwise. If called from Lisp, enable the mode if
-ARG is omitted or nil.
-
-Objed mode is a global minor mode. When enabled, any command
-configured in `objed-cmd-alist' will activate modal navigation
-and editing features on text objects. Available commands,
-operations and objects can be found in `objed-map',
-`objed-op-map' and `objed-object-map'.
-
-To define your own text objects and editing operations see
-`objed-define-object' and `objed-define-op'.
-
-Activating this mode loads the optional dependencies `which-key'
-and `avy' if they are available. This can be deactivated by
-setting the user options `objed-use-which-key-if-available-p' and
-`objed-use-avy-if-available-p' before loading."
- :global t
- :require 'objed
- (if objed-mode
- (progn
- (setq objed--which-key-avail-p (when objed-use-which-key-if-available-p
- (require 'which-key nil t))
- objed--avy-avail-p (when objed-use-avy-if-available-p
- (require 'avy nil t)))
- (objed--install-advices objed-cmd-alist t))
- (objed--remove-advices objed-cmd-alist)))
-
-
-(defun objed--install-advices (alist &optional do-not-save)
- "Install advices according to ALIST.
-
-If DO-NOT-SAVE is non-nil don't store ALIST entries in
-`objed-cmd-alist'."
- (dolist (cmd2obj alist)
- (unless do-not-save (push cmd2obj objed-cmd-alist))
- (advice-add (car cmd2obj) :after
- (apply-partially #'objed--activate (car cmd2obj)))
- (advice-add (car cmd2obj) :before 'objed--save-start-position)))
-
-(defun objed--remove-advices (alist)
- "Remove advices accroding to ALIST.
-
-See `objed-cmd-alist'."
- (dolist (cmd2obj alist)
- (advice-remove (car cmd2obj)
- (apply-partially #'objed--activate (car cmd2obj)))
- (advice-remove (car cmd2obj) 'objed--save-start-position)))
-
-
;; * Customization
(defgroup objed nil
@@ -515,6 +450,7 @@ To avoid loading `avy' set this var before activating
`objed-mode.'"
(defvar which-key--using-top-level nil)
(defvar avy-all-windows nil)
(defvar avy-action nil)
+(defvar mc/cursor-specific-vars nil)
(declare-function objed--exit-objed "objed" nil t)
(declare-function electric-pair-post-self-insert-function "ext:electric")
@@ -523,6 +459,9 @@ To avoid loading `avy' set this var before activating
`objed-mode.'"
(declare-function avy--process "ext:avy")
(declare-function avy--style-fn "ext:avy")
(declare-function edit-indirect-region "ext:edit-indirect")
+(declare-function electric-pair-syntax-info "ext:elec-pair")
+
+
;; * Support for other libs
@@ -609,11 +548,6 @@ interferring with `objed'."
(set-cursor-color objed-cursor-color)))))
-(defvar objed--dispatch-alist nil
- "Maps prefix commands to functions.
-
-Don't modify this list manually, use `objed-define-dispatch'.")
-
(defvar objed--dispatch-key-alist nil
"Store keys for dispatch commands.")
@@ -639,11 +573,43 @@ object as an argument."
;; save for possible reinit of objed-map
(push (cons ,key ',dp) objed--dispatch-key-alist))))
-(defmacro objed--save-state (&rest body)
- "Preserve state during execution of BODY."
- `(let ((state (objed--get-current-state)))
- (unwind-protect (progn ,@body )
- (prog1 nil (objed--restore-state state)))))
+(defvar objed-mode nil)
+(defvar objed--buffer nil
+ "Buffer where objed got initialized.")
+
+(defvar objed--dispatch-alist nil
+ "Maps prefix commands to functions.
+
+Don't modify this list manually, use `objed-define-dispatch'.")
+
+(defun objed--object-dispatch (name)
+ "Dispatch according to object NAME.
+
+Uses `objed--dispatch-alist' and defaults to
+update to given object."
+ (let* ((cmd (key-binding
+ (vector ;; (aref (this-command-keys-vector) 0)
+ last-command-event)))
+ (binding (assq cmd objed--dispatch-alist)))
+ (cond (binding
+ (funcall (cdr binding) name))
+ (t
+ ;; object called as command via M-x
+ (when (not objed--buffer)
+ (objed--init name))
+ ;; TODO: do something useful if called twice?
+ ;; (eq name objed--object)
+ (when (objed--switch-to name)
+ (goto-char (objed--beg)))))))
+
+
+(defun objed--get-object-for-cmd (cmd)
+ "Guess which object to use.
+
+CMD is the command for which object should be guessed. Returns
+the guessed object."
+ (let ((c (cdr (assq cmd objed-cmd-alist))))
+ (if (consp c) (objed--at-p c) c)))
;; * Keymaps
@@ -944,6 +910,12 @@ Use `objed-define-dispatch' to define a dispatch command.")
:beg start
:end (objed--max o))))))
+(defmacro objed--save-state (&rest body)
+ "Preserve state during execution of BODY."
+ `(let ((state (objed--get-current-state)))
+ (unwind-protect (progn ,@body )
+ (prog1 nil (objed--restore-state state)))))
+
(defun objed--mark-all-inside (name)
"Mark all objects of current type inside object NAME."
(save-excursion
@@ -1035,12 +1007,6 @@ and end postion will be used for toggle."
(defvar objed--saved-cursor nil
"Cursor color before objed got initialized.")
-(defvar objed--buffer nil
- "Buffer where objed got initialized.")
-
-(defvar objed--block-p nil
- "Block advices installed by `objed'.")
-
(defvar objed--hl-cookie nil
"The remapping cookie for `hl-line' face.")
@@ -1675,14 +1641,6 @@ Uses `objed-initial-object' for initialization."
(objed--init objed-initial-object))
-(defun objed--goto-char (pos)
- "Move to position POS possibly skipping leading whitespace."
- (goto-char
- (if (eq objed--object 'char)
- pos
- (objed--skip-forward pos 'ws))))
-
-
(defun objed-toggle-side ()
"Move to other side of object.
@@ -1709,13 +1667,6 @@ Default to sexp at point."
(objed--end))))))
-(defun objed--indentation-position ()
- "Get buffer position of indentation on current line."
- (save-excursion
- (back-to-indentation)
- (point)))
-
-
(defun objed-select-object ()
"Select current object with active region."
(interactive)
@@ -2201,7 +2152,7 @@ Moves point over any whitespace afterwards."
(interactive)
(objed--indent #'indent-rigidly-right-to-tab-stop))
-(defun objed-indent-rigidly (beg end &optional arg)
+(defun objed-indent-rigidly (_beg _end &optional arg)
"Similar to `indent-rigidly' but work on current object lines."
(interactive "r\nP")
(if arg
@@ -2716,6 +2667,70 @@ on."
(setq objed--buffer nil))))
+;; * Objed Mode
+
+(defvar objed-mode-map
+ (let ((map (make-sparse-keymap)))
+ ;; because objed is a "big" addition to the interface overriding M-SPC
might
+ ;; be ok
+ (define-key map (kbd "M-SPC") 'objed-activate)
+ ;;(define-key map (kbd "C-.") 'objed-activate)
+ map)
+ "Keymap for /function`objed-mode'.")
+
+;;;###autoload
+(define-minor-mode objed-mode
+ "Enable objeds modal editing features after certain commands.
+
+With a prefix argument ARG, enable Objed mode if ARG is positive,
+and disable it otherwise. If called from Lisp, enable the mode if
+ARG is omitted or nil.
+
+Objed mode is a global minor mode. When enabled, any command
+configured in `objed-cmd-alist' will activate modal navigation
+and editing features on text objects. Available commands,
+operations and objects can be found in `objed-map',
+`objed-op-map' and `objed-object-map'.
+
+To define your own text objects and editing operations see
+`objed-define-object' and `objed-define-op'.
+
+Activating this mode loads the optional dependencies `which-key'
+and `avy' if they are available. This can be deactivated by
+setting the user options `objed-use-which-key-if-available-p' and
+`objed-use-avy-if-available-p' before loading."
+ :global t
+ :require 'objed
+ (if objed-mode
+ (progn
+ (setq objed--which-key-avail-p (when objed-use-which-key-if-available-p
+ (require 'which-key nil t))
+ objed--avy-avail-p (when objed-use-avy-if-available-p
+ (require 'avy nil t)))
+ (objed--install-advices objed-cmd-alist t))
+ (objed--remove-advices objed-cmd-alist)))
+
+
+(defun objed--install-advices (alist &optional do-not-save)
+ "Install advices according to ALIST.
+
+If DO-NOT-SAVE is non-nil don't store ALIST entries in
+`objed-cmd-alist'."
+ (dolist (cmd2obj alist)
+ (unless do-not-save (push cmd2obj objed-cmd-alist))
+ (advice-add (car cmd2obj) :after
+ (apply-partially #'objed--activate (car cmd2obj)))
+ (advice-add (car cmd2obj) :before 'objed--save-start-position)))
+
+(defun objed--remove-advices (alist)
+ "Remove advices accroding to ALIST.
+
+See `objed-cmd-alist'."
+ (dolist (cmd2obj alist)
+ (advice-remove (car cmd2obj)
+ (apply-partially #'objed--activate (car cmd2obj)))
+ (advice-remove (car cmd2obj) 'objed--save-start-position)))
+
(provide 'objed)
;;; objed.el ends here
- [elpa] externals/objed c0a65ec 108/216: Remove redundant iblock object, (continued)
- [elpa] externals/objed c0a65ec 108/216: Remove redundant iblock object, Stefan Monnier, 2019/01/08
- [elpa] externals/objed b9fe335 117/216: Improve nav for objects with leading ws, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 7961536 113/216: Adjust textblock object again, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 64ed598 130/216: Mark other instances if object command is called repeatedly, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 333a9d5 120/216: Fix not loading mc variable if mc is loaded late, Stefan Monnier, 2019/01/08
- [elpa] externals/objed fe5548c 138/216: Install advices for :commands after objed is loaded, fixes #21, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 5b4bf3f 128/216: Get region command positions according to objed rules, Stefan Monnier, 2019/01/08
- [elpa] externals/objed a246088 144/216: Merge pull request #23 from gergelypolonkai/defcustom-fixes, Stefan Monnier, 2019/01/08
- [elpa] externals/objed c846b15 141/216: Init only where C-n is bound to something other than next-line, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 50c2367 155/216: Mention move objects functionality, Stefan Monnier, 2019/01/08
- [elpa] externals/objed f8af251 080/216: General cleanup,
Stefan Monnier <=
- [elpa] externals/objed 72053b7 109/216: Simplify macro usage again, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 9558b39 098/216: Add ace char object, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 49082c7 167/216: Accept 1 as universal arg, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 185fe41 111/216: Remove unused lexical var, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 8a74424 125/216: Optimize init/reset procedure, avoid unnecessary re-initialization, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 9c1b350 067/216: Update link, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 7abf5b3 091/216: Fixes #3, switch to remote object with '#', Stefan Monnier, 2019/01/08
- [elpa] externals/objed 7ba5cb2 088/216: New until beg/end of buffer behavior, Stefan Monnier, 2019/01/08
- [elpa] externals/objed 22392cf 099/216: Add whitepsace objects, fixes #2, Stefan Monnier, 2019/01/08
- [elpa] externals/objed f3efa0e 121/216: Don't let sentence object jump over to next comments/string, Stefan Monnier, 2019/01/08