Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emacs function to case-insensitive sort-lines?

Tags:

emacs

elisp

I know that you can do the following to sort-lines in emacs without case sensitivity:

M-x set-variable [RETURN] sort-fold-case [RETURN] t [RETURN] M-x sort-lines M-x set-variable [RETURN] sort-fold-case [RETURN] nil [RETURN] 

But this is annoying to do every time. How can I turn this into a function so that I don't have to do the same thing over and over?

like image 742
Phillip B Oldham Avatar asked Jan 07 '14 09:01

Phillip B Oldham


2 Answers

Pretty straightforward:

(defun sort-lines-nocase ()   (interactive)   (let ((sort-fold-case t))     (call-interactively 'sort-lines))) 
like image 126
abo-abo Avatar answered Oct 11 '22 15:10

abo-abo


If you always want to sort case insensitive, try this in a file used on startup:

(custom-set-variables  '(sort-fold-case t t) ) 

Then you can just call M-x sort-lines.

like image 32
maurits Avatar answered Oct 11 '22 17:10

maurits