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

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

[elpa] externals/objed 084c9ea 39/59: Adding toggle identifier place com


From: Clemens Radermacher
Subject: [elpa] externals/objed 084c9ea 39/59: Adding toggle identifier place command
Date: Sun, 24 Mar 2019 06:06:41 -0400 (EDT)

branch: externals/objed
commit 084c9ea24b7ce279823ad0518d5512a115574d07
Author: Clemens Radermacher <address@hidden>
Commit: Clemens Radermacher <address@hidden>

    Adding toggle identifier place command
---
 objed.el | 34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)

diff --git a/objed.el b/objed.el
index d0428ed..30f4036 100644
--- a/objed.el
+++ b/objed.el
@@ -768,7 +768,7 @@ selected one."
     ;; direct object switches
     (define-key map "." 'objed-goto-next-identifier)
     (define-key map "," 'objed-goto-prev-identifier)
-    (define-key map "_" 'objed-symbol-object)
+    (define-key map "_" 'objed-toggle-indentifier-place)
     (define-key map "l" 'objed-line-object)
     ;;(define-key map "%" 'objed-contents-object)
 
@@ -846,6 +846,7 @@ Other single character keys are bound to `objed-undefined'."
     (define-key map "x" 'objed-eval-defun)
     (define-key map "e" 'objed-eval-exp)
     (define-key map "y" 'objed-insert)
+    (define-key map "i" 'insert-file)
     (define-key map "q"
       (objed-define-op nil objed-reformat-op ignore))
     (define-key map "r" ctl-x-r-map)
@@ -1996,6 +1997,37 @@ On repeat move to next."
   (when (objed--switch-to 'identifier)
     (goto-char (objed--beg))))
 
+(let (state)
+  (defun objed-toggle-indentifier-place ()
+    "Toggle between current and special places of identifier.
+
+Special places are for example defintion declarations or key
+bindings."
+    (interactive)
+    (when (eq major-mode 'emacs-lisp-mode)
+      (cond ((eq last-command 'objed-goto-definition)
+             (objed--restore-state state))
+            (t
+             (unless (eq objed--object 'identifier)
+               (objed--switch-to 'identifier)
+               (goto-char (objed--beg)))
+             (when (eq this-command 'objed-toggle-indentifier-place)
+               (setq state (objed--get-current-state)))
+             (let* ((format (objed--get-ident-format))
+                    (pos (save-excursion
+                           (goto-char (point-min))
+                           (when (re-search-forward
+                                  (format "(def.*? \\(%s\\)" format) nil t)
+                             (match-beginning 1)))))
+               (if (and pos (not (= pos (point))))
+                   (progn (goto-char pos)
+                          (objed--switch-to 'identifier)
+                          (setq this-command 'objed-goto-definition))
+                 (objed-top-object)
+                 (when (and pos (= pos (point)))
+                   (objed-bottom-object)))))))))
+
+
 (defun objed-goto-next-identifier ()
   "Switch to next identifier."
   (interactive)



reply via email to

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