From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Gary Wessle Newsgroups: gmane.emacs.help Subject: insert new line at ";" C++ Date: 03 Oct 2006 06:12:52 +1000 Organization: iPrimus Customer - reports relating to abuse should be sent to abuse@iprimus.com.au Message-ID: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1159821708 18795 80.91.229.2 (2 Oct 2006 20:41:48 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 2 Oct 2006 20:41:48 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Oct 02 22:41:38 2006 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GUUbC-0002T0-2L for geh-help-gnu-emacs@m.gmane.org; Mon, 02 Oct 2006 22:41:14 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GUUbB-0003ZO-KG for geh-help-gnu-emacs@m.gmane.org; Mon, 02 Oct 2006 16:41:13 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!newscon04.news.prodigy.net!prodigy.net!news.linkpendium.com!news.linkpendium.com!newsfeed.pacific.net.au!token.pipenetworks.com!218.100.2.59.MISMATCH!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 X-Original-NNTP-Posting-Host: 202.67.78.98 X-Original-NNTP-Posting-Host: 127.0.0.1 Original-Lines: 195 Original-NNTP-Posting-Host: 203.134.67.67 Original-X-Trace: 1159819918 un-2park-reader-01.sydney.pipenetworks.com.au 4674 203.134.67.67:4832 Original-X-Complaints-To: Abuse, including message IDs to abuse@pipenetworks.com Original-Xref: shelby.stanford.edu gnu.emacs.help:142147 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:37766 Archived-At: Hi On a dual boot box, in one OS, I have the C++ mode working as I like it, but now I am working with another OS which has its own emacs. I remember reading that it is best to customize emacs through its own customization interface "M-x customize-variable..." rather than adding lines in your .emacs file which so fare I have been successful in doing until now. why, well, now I need to have emacs "in the C++" mode to insert a new line once I type things like ")" "]" "}" ";" and the like. is there a way to do this without coping things from my old .emacs file? ok, here is my current .emacs file and below it is the section from my old .emacs which does all the C++ goodies that I will eventually need to incorporate into my new .emacs **************************************************************** ;; .emacs ;;; uncomment this line to disable loading of "default.el" at startup ;; (setq inhibit-default-init t) ;; turn on font-lock mode (when (fboundp 'global-font-lock-mode) (global-font-lock-mode t)) ;; enable visual feedback on selections ;(setq transient-mark-mode t) ;; default to better frame titles (setq frame-title-format (concat "%b - emacs@" (system-name))) ;; default to unified diffs (setq diff-switches "-u") ;; always end a file with a newline ;(setq require-final-newline 'query) (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. '(column-number-mode t) '(default-major-mode (quote text-mode)) '(display-time-24hr-format t) '(display-time-day-and-date t) '(display-time-mode t nil (time)) '(inhibit-startup-message t) '(kill-whole-line t) '(make-backup-files nil) '(menu-bar-mode t) '(text-mode-hook (quote (flyspell-mode turn-on-auto-fill text-mode-hook-identify))) '(tool-bar-mode nil nil (tool-bar)) '(visible-bell 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 (:stipple nil :background "black" :foreground "white" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 119 :width normal :family "adobe-courier"))))) (put 'erase-buffer 'disabled nil) ;; ************************************************* ;; *********** my manual add-on section ************ ;; ************************************************* ;; makes a vertical split along the horisontal line (defun htv-horizontal-to-vertical () (interactive) (let ((one-buf (window-buffer (selected-window))) (buf-point (point))) (other-window 1) (delete-other-windows) (split-window-horizontally) (switch-to-buffer one-buf) (goto-char buf-point))) ;; makes a vertical split along the horisontal line (defun vth-vertical-to-horizontal () (interactive) (let ((one-buf (window-buffer (selected-window))) (buf-point (point))) (other-window 1) (delete-other-windows) (split-window-vertically) (switch-to-buffer one-buf) (goto-char buf-point))) ;; don't show password (add-hook 'comint-output-filter-functions 'comint-watch-for-password-prompt) ;; copying functions (global-set-key "\C-cw" "\M-b\C-@\M-f\M-w") ; word under point (global-set-key "\C-cl" "\C-a\C-@\C-e\M-w") ; line under point (global-set-key "\C-cs" "\M-a\C-@\M-e\M-w") ; sentence under point (global-set-key "\C-cp" "\M-h\C-f\M-w") ; paragraph under point ;; cut all the ^M (global-set-key [f10] 'cut-ctrlM) (defun cut-ctrlM () "Cut all visible ^M." (interactive) (beginning-of-buffer) (while (search-forward "\r" nil t) (replace-match "" nil t)) ) ;; makes relavent files executable (add-hook 'after-save-hook #'executable-make-buffer-file-executable-if-script-p) ;; hideshow for programming (load-library "hideshow") (add-hook 'c++-mode-hook 'hs-minor-mode) ;; key bindings (windmove-default-keybindings) ;Shift-arrow moves focus (global-set-key [f5] (kbd "M-h M-C-\\")) ;indent region according to mode (global-set-key [f6] 'setnu-mode) ;set-number use twice after C-y (global-set-key "\C-x\C-b" 'buffer-menu) ;binds the key C-x C-b to buffer-menu (global-set-key [f7] (kbd "M-h M-;")) ;comment region (global-set-key [f11] 'compile) ;compiles a program ;; hitting shift-f8 will save the current buffer with permission 700 (defun chmod-save () "Save and chmod 700 current buffer" (interactive) (save-buffer) (setq command (concat "chmod 700 " (buffer-file-name))) (message "%s " command) (shell-command command) ) (global-set-key [(shift f8)] 'chmod-save) **************************************************************** *************************** end ******************************** **************************************************************** here is my C++ goodies from my old .emacs (load "~/.emacs-mc394") ... (add-hook 'c++-mode-hook '(lambda () (turn-on-auto-fill) ;;Insert a newline if line gets to long. (c-toggle-auto-state 1) ;;Make ; and { and } and : all electric (c-set-style "mc394-style"))) (add-hook 'c++-mode-hook 'setnu-mode) ;line numbers (add-hook 'c++-mode-hook 'bar-cursor-mode) ;cursor to a bar (add-hook 'c++-mode-hook 'show-paren-mode) ;marrying brackets show here is .emacs-mc394 **************************************************************** ;; Modified by Mike Hvidsten from MC38J emacs file ;; Feb. 4, 2004 (c-add-style "mc394-style" '("cc-mode" (c-basic-offset . 3) ; In general, indent 3 spaces (c-hanging-braces-alist (defun-open after)) ; brace that opens a function definition (c-cleanup-list brace-else-brace brace-elseif-brace empty-defun-braces defun-close-semi scope-operator) (c-hanging-braces-alist ; These determine whether a newline appears before ; and/or after a brace in various situations. (brace-list-open) (block-open after) ; statement block open brace (defun-open after) ; brace that opens a function definition (substatement-open after); the brace that opens a substatement block (block-close . c-snug-do-while)) (c-hanging-colons-alist (access-label after)) ; Newline after protected: or private: (c-hungry-delete-key t))) ; delete black space all at once ;; Variable should be t if we are running xemacs. (defvar xemacs-p (string-match "XEmacs" emacs-version)) (if (not xemacs-p) (progn (global-font-lock-mode t) ; If using global-font-lock-mode, make control-L update colors (global-set-key "\C-l" (function (lambda (arg) (interactive "P") (font-lock-fontify-block 100) (recenter arg)))))) (setq auto-mode-alist (append '(("\\.h$" . c++-mode)) auto-mode-alist))