emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/objed cf1db37 140/216: Allow users to define a function


From: Stefan Monnier
Subject: [elpa] externals/objed cf1db37 140/216: Allow users to define a function to allow/prevent objed init
Date: Tue, 8 Jan 2019 12:29:27 -0500 (EST)

branch: externals/objed
commit cf1db37de54d52a648c443e5671bb8fb31a89cbc
Author: Clemera <address@hidden>
Commit: Clemera <address@hidden>

    Allow users to define a function to allow/prevent objed init
---
 objed.el | 30 +++++++++++++++++++-----------
 1 file changed, 19 insertions(+), 11 deletions(-)

diff --git a/objed.el b/objed.el
index 0e58552..0aa8be5 100644
--- a/objed.el
+++ b/objed.el
@@ -91,7 +91,7 @@
 ;; `objed-define-object'.
 ;;
 ;; Although some features are still experimental the basic user interface will
-;; stay the same. 
+;; stay the same.
 ;;
 ;;
 ;; CONTRIBUTE:
@@ -155,9 +155,8 @@
 
 ;; * User Settings and Variables
 
-(defcustom objed-disabled-modes
-  '(special-mode dired-mode)
-  "List of modes for which objed should stay disabled.
+(defcustom objed-disabled-modes '()
+    "List of modes for which objed should stay disabled.
 
 If the current `major-mode' is in the list or derives from a
 member of it `objed' will not activate.
@@ -166,6 +165,11 @@ See also `objed-disabled-p'"
   :group 'objed
   :type '(repeat symbol))
 
+(defcustom objed-init-p-function #'objed-init-p
+  "Function which test if objed is allowd to initialize.
+
+The function should return nil if objed should not initialize.")
+
 
 (defcustom objed-cmd-alist
   '(
@@ -307,7 +311,6 @@ removed."
   :type 'symbol)
 
 
-
 ;; optional dep options
 
 (defcustom objed-use-which-key-if-available-p t
@@ -1012,11 +1015,8 @@ See `objed-cmd-alist'."
              (not objed-disabled-p)
              (not (eq (cadr overriding-terminal-local-map)
                       objed-map))
-             ;; (memq (key-binding "q")
-             ;;            '(self-insert-command
-             ;;              outshine-self-insert-command
-             ;;              org-self-insert-command))
-             (or (memq major-mode '(messages-buffer-mode help-mode))
+             (funcall objed-init-p-function)
+             (or (not objed-disabled-modes)
                  (not (apply 'derived-mode-p objed-disabled-modes))))
       (objed--init cmd)))
 
@@ -1045,7 +1045,15 @@ See `objed-cmd-alist'."
   ;; use the mark instead
   (if (eq this-command #'end-of-buffer)
       (objed--change-to :beg (mark) :ibeg (mark))
-      (objed--change-to :beg pos :ibeg pos)))
+    (objed--change-to :beg pos :ibeg pos)))
+
+(defun objed-init-p ()
+  "Default for `objed-init-p-function'."
+  (memq (key-binding "n")
+        '(self-insert-command
+          outshine-self-insert-command
+          org-self-insert-command
+          undefined)))
 
 (defun objed--init (&optional sym)
   "Initialize `objed'.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]