* vimpulse C-o not using global marks ?!?
@ 2010-07-22 15:05 TheLonelyStar
2010-07-23 14:16 ` Štěpán Němec
0 siblings, 1 reply; 2+ messages in thread
From: TheLonelyStar @ 2010-07-22 15:05 UTC (permalink / raw)
To: Help-gnu-emacs
Hi,
I use vimpulse. When I do C-o it jumps to the last mark in the current file.
Can i somehow make it use global marks?
Thanks!
Nathan
--
View this message in context: http://old.nabble.com/vimpulse-C-o-not-using-global-marks--%21--tp29237973p29237973.html
Sent from the Emacs - Help mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: vimpulse C-o not using global marks ?!?
2010-07-22 15:05 vimpulse C-o not using global marks ?!? TheLonelyStar
@ 2010-07-23 14:16 ` Štěpán Němec
0 siblings, 0 replies; 2+ messages in thread
From: Štěpán Němec @ 2010-07-23 14:16 UTC (permalink / raw)
To: TheLonelyStar; +Cc: implementations-list, Help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 767 bytes --]
TheLonelyStar <nabble2@lonely-star.org> writes:
> Hi,
>
> I use vimpulse. When I do C-o it jumps to the last mark in the current file.
> Can i somehow make it use global marks?
Hi,
let's have this discussion on the vim-emulation list, which I am hereby
Cc:-ing (and please remove the help list from the Cc: header when
replying; I don't think most people here are interested in this).
I consider this to be a problem, too, and even started to implement it
before some time, but as I almost never use it and nobody else seemed to
ever mention this, it remained a stub, i.e. it sort-of works, but a bit
funnily and not quite as in Vim (yet). Here is what I came up with (you
can apply the diff provided you use the Git repository, not the single
vimpulse.el file):
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: global-jumps.diff --]
[-- Type: text/x-diff, Size: 6058 bytes --]
diff --git a/vimpulse-dependencies.el b/vimpulse-dependencies.el
index 692e823..1e31753 100644
--- a/vimpulse-dependencies.el
+++ b/vimpulse-dependencies.el
@@ -215,16 +215,13 @@ (defvar vimpulse-core-movement-cmds
"List of Viper \"core\" movement commands.
These should be present in every mode, to avoid confusion.")
-(viper-deflocalvar vimpulse-mark-list nil
- "List of mark positions to jump to with `vimpulse-jump-forward'.
- They are stored as markers, the current position first:
-
- (car vimpulse-mark-list) = current position (last popped)
- (cdr vimpulse-mark-list) = future positions (previously popped)
- (cadr vimpulse-mark-list) = next position (to jump to)
+(defvar vimpulse-jump-list-max 100
+ "Maximum number of jumps to store.")
- In other words, a sort of \"reverse mark ring\": marks that are
- popped off the mark ring, are collected here.")
+(defvar vimpulse-jump-list (make-ring vimpulse-jump-list-max)
+ "List of mark positions to jump to with `vimpulse-jump-forward'.
+\(The actual data structure used is a ring, not list.)
+They are stored as markers, the current position first.")
(viper-deflocalvar vimpulse-local-marks-alist nil
"Association list of local marks.
diff --git a/vimpulse-misc-keybindings.el b/vimpulse-misc-keybindings.el
index 7832afd..e18fa7a 100644
--- a/vimpulse-misc-keybindings.el
+++ b/vimpulse-misc-keybindings.el
@@ -500,58 +500,69 @@ (defalias 'viper-autoindent 'vimpulse-autoindent)
;;; C-o, C-i
-(defadvice set-mark (after vimpulse activate)
- "Clear `vimpulse-mark-list'."
- (mapc (lambda (marker)
- (set-marker marker nil))
- vimpulse-mark-list)
- (setq vimpulse-mark-list nil))
-
-(defadvice push-mark (after vimpulse activate)
- "Clear `vimpulse-mark-list'."
- (mapc (lambda (marker)
- (set-marker marker nil))
- vimpulse-mark-list)
- (setq vimpulse-mark-list nil))
+;; TODO / %
+(defvar vimpulse-jump-commands
+ '(vimpulse-jump-to-tag-at-point viper-backward-paragraph
+ viper-forward-paragraph viper-backward-sentence viper-forward-sentence
+ viper-brac-function viper-goto-line viper-goto-mark
+ viper-goto-mark-and-skip-white viper-search-next viper-search-Next
+ viper-window-bottom viper-window-middle viper-window-top)
+ "Commands that constitute a \"jump\".")
+
+(defun vimpulse-record-jump ()
+ (ring-insert vimpulse-jump-list
+ (cons buffer-file-name (move-marker (make-marker) (point)))))
+
+(defmacro vimpulse-jump-advice (fun)
+ (let ((funcname (symbol-value fun)))
+ `(defadvice ,funcname (before vimpulse-record-jump activate)
+ (vimpulse-record-jump))))
+
+(dolist (c vimpulse-jump-commands)
+ (vimpulse-jump-advice c))
+
+(defvar vimpulse-jump-list-curpos nil)
+
+(defun vimpulse-jump-to (pos)
+ (let ((file (car pos))
+ (marker (cdr pos)))
+ (if (equal buffer-file-name file)
+ (goto-char marker)
+ (if (null file)
+ (if (marker-buffer marker)
+ (progn (switch-to-buffer (marker-buffer marker))
+ (goto-char marker))
+ (message "Buffer does not exist, removing from jump list")
+ (ring-remove vimpulse-jump-list vimpulse-jump-list-curpos))
+ (or (and (or (find-buffer-visiting file)
+ (y-or-n-p (format "Visit file %s again? " file)))
+ (find-file file)
+ (goto-char marker))
+ (message "Kthx"))))))
(defun vimpulse-jump-backward (arg)
"Go to older position in jump list.
- To go the other way, press \\[vimpulse-jump-forward]."
+For the opposite direction, use \\[vimpulse-jump-forward]."
(interactive "p")
- (let ((current-pos (make-marker)) i)
- (unless vimpulse-mark-list
- (move-marker current-pos (point))
- (add-to-list 'vimpulse-mark-list current-pos))
- (dotimes (arg arg)
- (setq current-pos (make-marker))
- ;; Skip past duplicate entries in the mark ring.
- (setq i (length mark-ring))
- (while (progn (move-marker current-pos (point))
- (let (vimpulse-mark-list)
- ;; Protect `vimpulse-mark-list'.
- (set-mark-command 0))
- (setq i (1- i))
- (and (= (point) current-pos) (> i 0))))
- ;; Already there?
- (move-marker current-pos (point))
- (unless (= (car vimpulse-mark-list) current-pos)
- (setq vimpulse-mark-list
- (cons current-pos vimpulse-mark-list))))))
+ (if (memq last-command '(vimpulse-jump-backward vimpulse-jump-forward))
+ (vimpulse-jump-to (ring-ref vimpulse-jump-list
+ (setq vimpulse-jump-list-curpos
+ (+ vimpulse-jump-list-curpos arg))))
+ (vimpulse-record-jump)
+ (vimpulse-jump-to (ring-ref vimpulse-jump-list
+ (setq vimpulse-jump-list-curpos arg)))))
(defun vimpulse-jump-forward (arg)
"Go to newer position in jump list.
- To go the other way, press \\[vimpulse-jump-backward]."
+For the opposite direction, use \\[vimpulse-jump-backward]."
(interactive "p")
- (let (current-pos next-pos)
- (dotimes (arg arg)
- (setq current-pos (car vimpulse-mark-list)
- next-pos (cadr vimpulse-mark-list))
- (when next-pos
- ;; Protect `vimpulse-mark-list'.
- (let (vimpulse-mark-list)
- (push-mark current-pos t nil))
- (goto-char next-pos)
- (setq vimpulse-mark-list (cdr vimpulse-mark-list))))))
+ (if (memq last-command '(vimpulse-jump-backward vimpulse-jump-forward))
+ (vimpulse-jump-to (ring-ref vimpulse-jump-list
+ (setq vimpulse-jump-list-curpos
+ (- vimpulse-jump-list-curpos arg))))
+ (vimpulse-record-jump)
+ (vimpulse-jump-to (ring-ref vimpulse-jump-list
+ (setq vimpulse-jump-list-curpos (- arg))))))
(when vimpulse-want-C-i-like-Vim
(define-key viper-vi-basic-map "\C-i" 'vimpulse-jump-forward))
[-- Attachment #3: Type: text/plain, Size: 15 bytes --]
Štěpán
[-- Attachment #4: Type: text/plain, Size: 199 bytes --]
_______________________________________________
implementations-list mailing list
implementations-list@lists.ourproject.org
https://lists.ourproject.org/cgi-bin/mailman/listinfo/implementations-list
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-07-23 14:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-22 15:05 vimpulse C-o not using global marks ?!? TheLonelyStar
2010-07-23 14:16 ` Štěpán Němec
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.