POV-Ray : Newsgroups : povray.unix : New release Pyvon : Re: What is the fuss about emacs ? Server Time
6 Oct 2024 13:18:55 EDT (-0400)
  Re: What is the fuss about emacs ?  
From: Warp
Date: 28 Nov 2002 03:42:55
Message: <3de5d70f@news.povray.org>
fabien Henon <fab### [at] caramailcom> wrote:
> ??? Could you tell me with which combination of keys I can have that.

  Emacs is quite ascetic by default, with really obfuscated key combination.
Also configuring it to work in a more "windows-editor-like" way requires lots
of complicated and obfuscated elisp code.
  However, once you have succeeded in configuring it the way you like, it's
really excellent.

  This is the .emacs I have configured for myself over the years. It will
work with GNU Emacs 21.* (currently I use 21.2.1). It has a couple of things
which won't work in Emacs 20.* (and there really isn't any reason to use
the older version anyways).
  I *don't* guarantee it will work with xemacs (most probably it won't), so
I suggest that you install emacs 21.* (IMHO it's better anyways). (And yes,
it will work in X and will open an X window where all colorings, key
combinations etc will work, has graphical menus, etc etc.)

  By using this .emacs file you will get lots of key combinations typical
to windows editors, automatic syntax highlighting, etc. Here is a short list
of some typical key combinations I use regularly:

  shift + cursor movement: Paint text (for copying). ("Cursor movement" means
*any* key or key combination that moves the cursor around, such as the ones
listed below.)

  Page up and page down: Move the cursor one screenful of lines up or down
(which is how it really *should* work and not how it works in emacs by
default, where it leaves the cursor in the last/first line).

  ctrl+up and ctrl+down: Scroll the screen up and down by one line.

  ctrl+left and ctrl+right: Move one word to the left and right.

  ctrl+backspace: Delete the word at the left of the cursor.

  ctrl+y: Kill the current line (which is different from ctrl+k)

  home and end: Move to the beginning and end of the line (instead of the
default emacs behaviour, which is to move to the beginning or end of the
whole file).

  ctrl+home and ctrol+end: Move to the beginning and end of the whole file.

  ctrl+ins: copy (painted text)
  shift+ins: paste
  shift+del: delete painted text

  And of course remember ctrl+_ (ie. undo) which is extremely handy.

  There are more features as well. Most of them are commented in the .emacs
itself, which is below. You should look through it and at least configure
the path to pov-mode.elc:

-----------8<-----------8<-----------8<-----------8<-----------8<-----------
;;; This line adds a LOT of stuff. Among other things it adds
;;; shift+cursor movement painting, ctrl-ins copying, shift-ins pasting, etc.
(pc-selection-mode)

;;; Show also column number besides line number:
(column-number-mode t)

;;; Doesn't add new lines at the end of the doc when cursor is there and
;;; cursor down is pressed:
(setq next-line-add-newlines nil)

;;; Don't create backup files:
(setq auto-save-default nil)
;;; Scroll one line at a time, not half-page:
(setq scroll-step 1)
;;; Colors:
(set-background-color "black")
(set-foreground-color "white")
;(set-face-background 'default "black") ; try if the above doesn't work
;(set-face-foreground 'default "white")
(set-cursor-color "yellow")

(standard-display-european t)
(set-input-mode 't 'nil 'foo)


;;; Fix home, end and delete to work as they should:
(global-set-key '[home] 'beginning-of-line)
(global-set-key '[end] 'end-of-line)
(global-set-key '[delete] 'delete-char)
;;; Use ctrl-y to kill a line immediately. Much handier than ctrl-k
(global-set-key "\C-y" 'kill-complete-line)
(global-set-key "\C-u" 'yank)
;;; Other key settings:
(global-set-key [(alt x)] 'save-buffers-kill-emacs)
(global-set-key [(alt f3)] 'delete-window)
(global-set-key '[f2] 'save-buffer)
(global-set-key '[f9] 'compile)
(global-set-key '[(control c) (control r)] 'font-lock-fontify-buffer)
(global-set-key "\C-r" 'insert-file)
;;; Fix bacspace to delete characters instead of popping up the help.
;;; To pop up the help, press F1.
(global-set-key "\C-h" 'delete-backward-char)

;;; Misc settings:
(auto-fill-mode)
(defun kill-complete-line ()
  "Kill the complete line."
  (interactive)
  (beginning-of-line)
  (if (eobp) (error "End of buffer"))
  (let ((beg (point)))
    (forward-line 1)
    (kill-region beg (point))))

(setq font-lock-maximum-decoration t)
(global-font-lock-mode t)


(setq backup-inhibited 't)

;;; Misc help functions:
(defun contents-move (dir checkpoint)
  (let ((oldColumn (current-column)))
    (if (not (pos-visible-in-window-p checkpoint))
        ((lambda ()
           (save-excursion
             (goto-char (window-start))
             (forward-line dir)
             (set-window-start (selected-window) (point))))))
    (forward-line dir)
    (move-to-column oldColumn)))

(defun contents-one-down ()
  (interactive)
  (contents-move -1 (point-min)))

(defun contents-one-up ()
  (interactive)
  (contents-move 1 (point-max)))

(defun generic-page-scroll (lines)
  (let ((oldColumn (current-column)))
    (save-excursion
      (goto-char (window-start))
      (forward-line lines)
      (set-window-start (selected-window) (point)))
    (forward-line lines)
    (move-to-column oldColumn)))

(defun page-scroll-up ()
  (interactive)
  (if (not (pos-visible-in-window-p (point-max)))
      (generic-page-scroll (- (1- (window-height)) next-screen-context-lines))
    (goto-char (point-max))))

(defun page-scroll-down ()
  (interactive)
  (if (not (pos-visible-in-window-p (point-min)))
      (generic-page-scroll (- next-screen-context-lines (1- (window-height))))
    (goto-char (point-min))))

;;; Use ctrl-up and ctrl-down to scroll:
(global-set-key '[(control up)] 'contents-one-down)
(global-set-key '[(control down)] 'contents-one-up)
;;; Fix page up and page down to work as they should:
(global-set-key '[next] 'page-scroll-up)
(global-set-key '[prior] 'page-scroll-down)

;; POV-Ray related stuff
;; =====================
(autoload 'pov-mode "/home/warp/temp/pov-mode.elc" "PoVray scene file mode" t)
(setq auto-mode-alist
      (append '(("\\.pov$" . pov-mode)
                ("\\.inc$" . pov-mode)
                ("\\.mcr$" . pov-mode))
              auto-mode-alist))
(add-hook 'pov-mode-hook 'turn-on-font-lock)


;;; Insert file at the current position uuencoded with ctrl-c-u
(defun insert-file-uuencoded (filename)
  (interactive "fInsert file (uuencoded): ")
  (shell-command (concat "uuencode " filename " " (substring filename (string-match
"[^/]+$" filename)) " | sed 's/^ $/`/'") t)
)

(global-set-key [(control c) (control u)] 'insert-file-uuencoded)

;;; Kill all whitespace chars forward from cursor with ctrl-t
(defun kill-white-space()
  (interactive)
  (if (re-search-forward "\\(\\s-\\|\n\\)+" nil t)
      (replace-match "")))

(global-set-key '[(control t)] 'kill-white-space)


;Color settings
(custom-set-variables
  ;; custom-set-variables was added by Custom -- don't edit or cut/paste it!
  ;; Your init file should contain only one such instance.
 '(case-fold-search t)
 '(current-language-environment "Latin-1")
 '(default-input-method "latin-1-prefix")
 '(global-font-lock-mode t nil (font-lock))
 '(lazy-lock-defer-on-the-fly nil)
 '(show-trailing-whitespace t)
 '(transient-mark-mode t))
(custom-set-faces
  ;; custom-set-faces was added by Custom -- don't edit or cut/paste it!
  ;; Your init file should contain only one such instance.
 '(default ((t (:foreground "white" :background "black"))))
 '(font-lock-builtin-face ((((class color) (background dark)) (:foreground "Green"))))
 '(font-lock-comment-face ((((class color) (background dark)) (:foreground
"ForestGreen"))))
 '(font-lock-constant-face ((((class color) (background dark)) (:foreground
"GreenYellow"))))
 '(font-lock-function-name-face ((((class color) (background dark)) (:foreground
"Coral"))))
 '(font-lock-keyword-face ((((class color) (background dark)) (:foreground
"Yellow"))))
 '(font-lock-string-face ((((class color) (background dark)) (:foreground
"Magenta"))))
 '(font-lock-type-face ((((class color) (background dark)) (:foreground "#40A0FF"))))
 '(font-lock-variable-name-face ((((class color) (background dark)) (:foreground
"thistle"))))
 '(modeline ((t (:foreground "yellow" :background "Blue"))))
 '(region ((t (:foreground "black" :background "#99CCFF"))))
 '(trailing-whitespace ((((class color) (background dark)) (:background "blue")))))


;;; C indentation settings
(defun oma-c-mode-common-hook ()
  (interactive)
  (setq c-basic-offset 4)
  (c-set-offset 'substatement-open 0)
  (c-set-offset 'case-label 2)
  (c-set-offset 'block-open 0)
  (c-set-offset 'knr-argdecl-intro '-)
  (c-set-offset 'arglist-close 'c-lineup-arglist)
  (c-set-offset 'access-label -3)
  (c-set-offset 'inclass 4)
  (c-set-offset 'inline-open 0)
  (setq tab-width 8
        ;; this will make sure spaces are used instead of tabs
        indent-tabs-mode nil)
)
(add-hook 'c-mode-common-hook 'oma-c-mode-common-hook)

;(require 'tex-site) ; Use this if you have tex-site installed and use LaTeX

(tool-bar-mode)
(set-default-font "9x15")
-----------8<-----------8<-----------8<-----------8<-----------8<-----------


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.