Reputation: 748
I have following needs on opening file with Emacs:
If you have the same functionalities implemented in your dotfile, It will be greatly appreciated if you could share it here.
Thanks!
Upvotes: 0
Views: 185
Reputation: 589
In elisp you can use a function like this, that you can put in your init.el
:
(let ((file-to-open (split-string (second command-line-args) ":")))
(progn
(find-file (first file-to-open))
(if (>= (length file-to-open) 2)
(progn (goto-char (point-min))
(forward-line
(- (string-to-int (second file-to-open)) 1))))
(if (= (length file-to-open) 3)
(forward-char
(- (string-to-int (third file-to-open)) 1)))))
Upvotes: 1
Reputation: 589
What about a bash function parsing the line and col parameters?
function myemacs { if echo $1 | grep -q ":" ; then COL=$(echo $1 | cut -d: -f3); emacs $(echo $1 | cut -d: -f1) +$(echo $1 | cut -d: -f2):${COL:-0}; else emacs $1; fi }
Upvotes: 0