Table of Contents

Emacs

Good to know

Cutting out a rectangle

To cut out a rectangle in emacs, mark the region in question with your mouse (upper left to lower right). Then press

ctrl-x r k

, which will cut out the rectangular region. Paste the rectangular region with

ctrl-x r y

Search for a string

If you want to search for a string, type

ctrl-s

If you want to search the same string as before, press:

ctrl-s ctrl-s

Configuring Emacs

Mousewheel on lxplus

If you use emacs on lxplus, the mousewheel isn't enabled. To add this functionality, open your ~/.emacs file and write in the following lines:

;; ====== mouse wheel 
;; ====== define scrolling functions 
(defun up-slightly () (interactive) (scroll-up 5))
(defun down-slightly () (interactive) (scroll-down 5))

(defun up-one () (interactive) (scroll-up 1))
(defun down-one () (interactive) (scroll-down 1))

(defun up-a-lot () (interactive) (scroll-up))
(defun down-a-lot () (interactive) (scroll-down))

(defun scroll-up-half ()
"Scroll up half a page."
(interactive)
(scroll-up (/ (window-height) 2))
)
(defun scroll-down-half ()
"Scroll down half a page."
(interactive)
(scroll-down (/ (window-height) 2))
)

;; ====== set mouse wheel to scrolling function 
;; ====== press shift + (mousewheel) for slow scrolling and 
;; ====== ctrl + (mousewheel) for fast scrolling 
(global-set-key [(mouse-5)] 'up-slightly)
(global-set-key [(mouse-4)] 'down-slightly)
(global-set-key [S-mouse-4] 'down-one)
(global-set-key [S-mouse-5] 'up-one)
(global-set-key [C-mouse-4] 'down-a-lot)
(global-set-key [C-mouse-5] 'up-a-lot)

The first four blocks of code define function for different scrolling speeds. In the second part, the mousewheel is assigned to a scrolling speed. Pressing shift oder ctrl while scrolling will alter the speed.

Numberpad on lxplus

By default, the keys on the numberpad are overloaded with different functionalities when using emacs in the LHCb environment on lxplus. If you want the standard numberpad, add the following to the ~/.emacs file:

(defun setnumpad()
  (interactive)
  (global-set-key [kp-decimal] '".")
  (global-set-key [kp-subtract] '"-")
  (global-set-key [kp-enter] '"\C-q \C-j")
  (global-set-key [kp-0]   '"0")
  (global-set-key [kp-1]   '"1")
  (global-set-key [kp-2]   '"2")
  (global-set-key [kp-3]   '"3")
  (global-set-key [kp-4]   '"4")
  (global-set-key [kp-5]   '"5")
  (global-set-key [kp-6]   '"6")
  (global-set-key [kp-7]   '"7")
  (global-set-key [kp-8]   '"8")
  (global-set-key [kp-9]   '"9")
 )

(defun setnonumpad()
  (interactive)
  (load (expand-file-name "$EMACSDIR/edt"))
)

After emacs has started, type alt-x setnumpad to activate the normal numberpad. If you want to deactivate it, type alt-x setnumpad. (Note: This is not very sophisticated, as just the configuration file is loaded again.)

Adding goto-line

A useful little command when coding with emacs is goto-line. To assign it a shortcut, add in your ~/.emacs:

;; == goto line ==
(define-key global-map "\C-xg" 'goto-line)

Goto-line then is executed with ctrl-x g.

Changing the font permanently

To permanently change the font in emacs, do the following:

(set-default-font "the font you want to choose")

for example

(set-default-font "-adobe-courier-medium-r-normal--12-120-75-75-m-70-iso8859-10")