Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

« Newer Snippets
Older Snippets »
3 total  XML / RSS feed 

Emacs: search for the selected text by Shift-clicking with the left mouse-button

First, we need a function that searches for the text that is currently selected. Add the following to your .emacs:

(defun mouse-search-forward (begin end)
  (interactive (list (point) (mark)))
  (let ((text (filter-buffer-substring begin end nil t)))
    (goto-char (max begin end))
    (let ((found-pos (search-forward text nil t)))
      (if (not found-pos)
          (progn
            (goto-char begin)
            (error "not found"))
          (progn
            (goto-char found-pos)
            (set-mark (- found-pos (length text))))))))


Now, we have to bind the function to the mouse-button. This is done by the following code, which you most likely also want to add to your .emacs:
(define-key global-map [(shift down-mouse-1)] nil)
(define-key global-map [(shift mouse-1)] 'mouse-search-forward)

Using gnus (emacs' mail and news reader) : Cheatsheet

1. Launch emacs
emacs &

2. Launch gnus
M-x gnus

3. Group Buffer
3.1. Subscribe to news groups
Check the group list
AA

Subscribe to a group (cursor above the group name)
u

3.2. Organise your topics
Create a new topic
T n

Assign a newsgroup to a topic
T m

3.3. Some more useful commands
RET = enter the newsgroup
g = check for new mails and news
q = quit
c = mark all unread as read (catchup)
C = mark all as read (catchup)
l = show newsgroup with unread articles
L = show all newsgroup
m = create a new mail (mails)
n = create a new post (news)

4. Summary/Article Buffer (useful commands)
RET = enter the article
n = next unread article
p = previous unread article
SPACE = scroll down
DEL = scroll up
F/f = Follow-up (with cite/whitout cite)
R/r = Reply (with cite/without cite)
m = create a new mail (mails)
a = create a new post (news)
c = mark as read (catchup)

5. Compose new mail and news
After creating a new mail or post (see above) use the following :
C-c C-c = send message
C-c C-d = save message as draft
C-c C-k = kill message
C-c C-m f = attach file
M-q = reformat paragraph

6. NEED HELP ?
C-h i gnus

Remote file editing using emacs + ssh

Get TRAMP (Transparent Remote file Access, Multiple Protocol) :
http://savannah.gnu.org/projects/tramp/


Install it :
cd ~/.emacs.d/
tar -xvzf /your/download/folder/tramp-2.X.X.tar.gz
ln -s tramp-2.X.X tramp
cd tramp
./configure --with-contrib
make
sudo make install


Configure your emacs to use it :
1. Add the following in your .emacs
;; Remote file editing via ssh
(add-to-list 'load-path "~/.emacs.d/tramp/lisp/")
(require 'tramp)
(setq tramp-default-method "ssh")

2. Launch your emacs
3. C-x C-f /[email protected]:/path/to/file

Warning :
Seems it doesn't work if no password is required to login to host (using public key for example). But not sure at all...
« Newer Snippets
Older Snippets »
3 total  XML / RSS feed