Am 02.02.2014 21:48, schrieb Sanel Zukan:
> Attached is updated patch: done small formatting fixes and added
> sorting mark characters.

Thanks. I'm not sure if your implementation does the same as Vim's.
AFAIK only capital letters denote global marks and the :marks command
should only show those marks that are accessible from the current
buffer, i.e. local marks set in the current buffer and global marks.

Your implementation collects all marks from all buffers. This means if
one has a large number of open buffers then the list would be cluttered
with a lot of marks that are local to each buffer, e.g. the '^' mark.
Furthermore you do not show global marks at all.

I've adapted your patch accordingly and hope it does the right thing.
But please check again and change whatever you like ;)

You may even consider to support the (optional) ex argument (using
(interactive "<a>"), which restricts the list of marks to be shown.

Best regards,
Frank

diff --git a/evil-commands.el b/evil-commands.el
--- a/evil-commands.el
+++ b/evil-commands.el
@@ -2692,6 +2692,44 @@
                           (cdr reg))))
         (newline)))))
 
+(evil-define-command evil-show-marks ()
+  "Shows all marks."
+  :repeat nil
+  ;; To get markers and positions, we can't rely on 'global-mark-ring'
+  ;; provided by Emacs (although it will be much simpler and faster),
+  ;; because 'global-mark-ring' does not store mark characters, but
+  ;; only buffer name and position. Instead, 'evil-markers-alist' is
+  ;; used; this is list maintained by Evil for each buffer.
+  (let (;; contains list of vectors in form [char-int row col filename]
+        all-markers)
+    (dolist (m (append (evil-filter-list #'(lambda (m)
+                                             (or (evil-global-marker-p (car m))
+                                                 (not (markerp (cdr m)))))
+                                         evil-markers-alist)
+                       (evil-filter-list #'(lambda (m)
+                                             (or (not (evil-global-marker-p
+                                                       (car m)))
+                                                 (not (markerp (cdr m)))))
+                                         (default-value 'evil-markers-alist))))
+      (with-current-buffer (marker-buffer (cdr m))
+        (save-excursion
+          (goto-char (cdr m))
+          (push (vector (car m)
+                        (1+ (count-lines 1 (line-beginning-position)))
+                        (current-column)
+                        (buffer-name))
+                all-markers))))
+    (evil-with-view-list "evil-marks"
+      (setq truncate-lines t)
+      (dolist (m (sort all-markers #'(lambda (a b)
+                                       (< (aref a 0)
+                                          (aref b 0)))))
+        (insert (format " %s %6d %6d %s\n"
+                        (string (aref m 0))
+                        (aref m 1)
+                        (aref m 2)
+                        (aref m 3)))))))
+
 (eval-when-compile (require 'ffap))
 (evil-define-command evil-find-file-at-point-with-line ()
   "Opens the file at point and goes to line-number."
_______________________________________________
implementations-list mailing list
[email protected]
https://lists.ourproject.org/cgi-bin/mailman/listinfo/implementations-list

Reply via email to