summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRavi R Kiran <aine.marina@gmail.com>2015-05-16 19:15:06 (GMT)
committerRavi R Kiran <aine.marina@gmail.com>2015-05-16 19:15:06 (GMT)
commit1859872533f8897d3e444488daa7e014e7421cb0 (patch)
tree5629833a273f29c5d24da03744846e87876f5d2f
parent9bd9a00a0d3412a88624027c8028b58f2bb3b60a (diff)
downloaddotemacs-1859872533f8897d3e444488daa7e014e7421cb0.zip
dotemacs-1859872533f8897d3e444488daa7e014e7421cb0.tar.gz
dotemacs-1859872533f8897d3e444488daa7e014e7421cb0.tar.bz2
Cleverer line positioning from emacsclient
-rw-r--r--lisp/ravi-init-function.el18
1 files changed, 18 insertions, 0 deletions
diff --git a/lisp/ravi-init-function.el b/lisp/ravi-init-function.el
index ee85393..da87931 100644
--- a/lisp/ravi-init-function.el
+++ b/lisp/ravi-init-function.el
@@ -31,6 +31,24 @@
;; Use emacsclient from other programs
(unless (server-running-p) (server-start))
+;; Stolen from prelude
+(defadvice server-visit-files (before parse-numbers-in-lines (files proc &optional nowait) activate)
+ "Open file with emacsclient with cursors positioned on requested line.
+Most of console-based utilities prints filename in format
+'filename:linenumber'. So you may wish to open filename in that format.
+Just call:
+emacsclient filename:linenumber
+and file 'filename' will be opened and cursor set on line 'linenumber'"
+ (ad-set-arg 0
+ (mapcar (lambda (fn)
+ (let ((name (car fn)))
+ (if (string-match "^\\(.*?\\):\\([0-9]+\\)\\(?::\\([0-9]+\\)\\)?$" name)
+ (cons
+ (match-string 1 name)
+ (cons (string-to-number (match-string 2 name))
+ (string-to-number (or (match-string 3 name) ""))))
+ fn))) files)))
+
;; Combined launcher and toggle-maps
(defun ravi/setup-toggle-launcher-map ()
(define-prefix-command 'ravi/toggle-launcher-map)