POV-Ray : Newsgroups : povray.unix : Emacs C++ mode with Windows shortcuts? : Re: Emacs C++ mode with Windows shortcuts? Server Time
28 Jul 2024 14:20:21 EDT (-0400)
  Re: Emacs C++ mode with Windows shortcuts?  
From: Warp
Date: 1 May 2001 07:23:58
Message: <3aee9ccd@news.povray.org>
Peter Popov <pet### [at] vipbg> wrote:
: That would be really nice. Either that, or e-mail the whole thing if
: it's not a problem.

  Ok, here it is:

-----------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.
;;; Works only in emacs, not in xemacs:
(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
;;; return 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-cursor-color "yellow")
(standard-display-european t) 
(set-input-mode (car (current-input-mode)) 
                (nth 1 (current-input-mode)) 
                0) 

;;; 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)
;;; 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 "\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) 

;;; 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
;; =====================
;;; Fix the path to pov-mode.elc!
(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-faces
 '(default ((t (:foreground "white" :background "black"))))
 '(font-lock-comment-face ((((class color) (background dark)) (:foreground
"ForestGreen"))))
 '(font-lock-string-face ((((class color) (background dark)) (:foreground
"Magenta"))))
 '(region ((t (:foreground "black" :background "#99CCFF"))))
 '(font-lock-keyword-face ((((class color) (background dark)) (:foreground
"Yellow"))))
 '(font-lock-constant-face ((((class color) (background dark)) (:foreground
"GreenYellow"))))
 '(font-lock-type-face ((((class color) (background dark)) (:foreground "#40A0FF"))))
 '(modeline ((t (:foreground "yellow" :background "Blue"))))
 '(font-lock-variable-name-face ((((class color) (background dark)) (:foreground
"thistle"))))
 '(font-lock-function-name-face ((((class color) (background dark)) (:foreground
"Coral"))))
 '(font-lock-builtin-face ((((class color) (background dark)) (:foreground
"Green")))))


;;; 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)

-----------8<-----------8<-----------8<-----------8<-----------8<-----------


-- 
#local D=array[6]{11117333955,7382340,3358,3900569407,970,4254934330}
#local I=0;#macro M()<mod(D[I],13)-6,mod(div(D[I],13),8)-3,10>#end
#while(I<6)cylinder{M()#local D[I]=div(D[I],104);M().1
pigment{rgb M()}}#local I=(D[I]>99?I:I+1);#end              /*- Warp -*/


Post a reply to this message

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