Hi all,

In attachment is a patch to support correct ':file' command, that
should provide basic information about file. Current implementation in
Evil is alias to ':files', which will incorrectly display available
buffers.

I tried to match Vim's output as much as possible. Also, I'm not sure
does Evil already provides some facilities for querying file
informations so I used Emacs api. Feel free to adjust it :)

Please let me know if something breaks.

PS: should I fill issue for this request?

Regards,
Sanel
diff --git a/evil-commands.el b/evil-commands.el
index 84880bf..63e1b60 100644
--- a/evil-commands.el
+++ b/evil-commands.el
@@ -2842,6 +2842,27 @@ Otherwise send [escape]."
   (setq this-command last-command)
   (add-hook 'pre-command-hook #'evil-turn-on-esc-mode nil t))
 
+(evil-define-command evil-show-file-info ()
+  "Shows basic file information."
+  (interactive)
+  (let* ((nlines   (line-number-at-pos (point-max)))
+         (curr     (line-number-at-pos (point)))
+         (nlinesf  (* nlines 1.0))
+         (currf    (* curr 1.0))
+         (perc     (* (/ currf nlinesf) 100))
+         (file     (buffer-file-name))
+         (writable (and file
+                        (file-writable-p file)))
+         readonly-str)
+
+    (if (and file (not writable))
+      (setq readonly-str "[readonly] ")
+      (setq readonly-str ""))
+    
+    (if file 
+      (message "\"%s\" %d %slines --%d%%--" file nlines readonly-str perc)
+      (message "%d lines --%d%%--" nlines perc))))
+
 (provide 'evil-commands)
 
 ;;; evil-commands.el ends here
diff --git a/evil-maps.el b/evil-maps.el
index 16f43bd..52ca391 100644
--- a/evil-maps.el
+++ b/evil-maps.el
@@ -384,6 +384,7 @@
 (evil-ex-define-cmd "marks" 'evil-show-marks)
 (evil-ex-define-cmd "ju[mps]" 'evil-show-jumps)
 (evil-ex-define-cmd "noh[lsearch]" 'evil-ex-nohighlight)
+(evil-ex-define-cmd "file" 'evil-show-file-info)
 (evil-ex-define-cmd "<" 'evil-shift-left)
 (evil-ex-define-cmd ">" 'evil-shift-right)
 (evil-ex-define-cmd "=" 'evil-ex-line-number)
_______________________________________________
implementations-list mailing list
[email protected]
https://lists.ourproject.org/cgi-bin/mailman/listinfo/implementations-list

Reply via email to