From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: denebet Newsgroups: gmane.emacs.help Subject: "Tab-fix" Date: Tue, 22 Jul 2008 08:22:58 +0200 Organization: les newsgroups par Orange Message-ID: <48857cc2$0$874$ba4acef3@news.orange.fr> Reply-To: denebet@lechebet.bzh NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 8Bit X-Trace: ger.gmane.org 1216756280 25694 80.91.229.12 (22 Jul 2008 19:51:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 22 Jul 2008 19:51:20 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Jul 22 21:52:08 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KLNti-0008Oo-CV for geh-help-gnu-emacs@m.gmane.org; Tue, 22 Jul 2008 21:51:47 +0200 Original-Received: from localhost ([127.0.0.1]:60852 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KLNso-0001Po-7l for geh-help-gnu-emacs@m.gmane.org; Tue, 22 Jul 2008 15:50:50 -0400 Original-Path: news.stanford.edu!newsfeed.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!news-fra1.dfn.de!feeder.erje.net!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!club-internet.fr!feedme-small.clubint.net!usenet-fr.net!ircam.fr!freenix!news.wanadoo.fr!news.wanadoo.fr!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: KNode/0.10.9 Original-Lines: 213 Original-NNTP-Posting-Date: 22 Jul 2008 08:22:59 CEST Original-NNTP-Posting-Host: 86.199.187.101 Original-X-Trace: 1216707779 news.orange.fr 874 86.199.187.101:2874 Original-X-Complaints-To: abuse@orange.fr Original-Xref: news.stanford.edu gnu.emacs.help:160432 X-Mailman-Approved-At: Tue, 22 Jul 2008 15:50:24 -0400 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:55819 Archived-At: I have put the stuff found at in my .emacs to get autocompletion bound to tab in C(++) editing mode while keeping the completion of file name in mini-buffers. (defun indent-or-expand (arg) "Either indent according to mode, or expand the word preceding point." (interactive "*P") (if (and (or (bobp) (= ?w (char-syntax (char-before)))) (or (eobp) (not (= ?w (char-syntax (char-after)))))) (dabbrev-expand arg) (indent-according-to-mode))) (defun my-tab-fix () (local-set-key [tab] 'indent-or-expand)) (add-hook 'c-mode-hook 'my-tab-fix) (add-hook 'sh-mode-hook 'my-tab-fix) (add-hook 'emacs-lisp-mode-hook 'my-tab-fix) Unfortunately, it seems not to work, at least while editing cpp files. Any idea ? TIA Alain I give my complete .emacs below. (setq load-path (cons "/usr/local/share/emacs/site-lisp" load-path)) (require 'tex-site) (setq TeX-auto-save t) (setq TeX-parse-self t) (setq-default TeX-master nil) (add-hook 'LaTeX-mode-hook 'turn-on-auto-fill) (setq TeX-parse-self t) ; Enable parse on load. ;;(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. ;; '(global-font-lock-mode t nil (font-lock))) ;;(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. ;; ) ;;(setq c-mode-hook '(lambda () (auto-fill-mode 1))) ;; And make text mode have auto-filling at column 80 (set-fill-column 80) (defun my-c-mode-hook () (auto-fill-mode) ) (add-hook 'c-mode-hook 'my-c-mode-hook) (setq magic-keys-mode t) ; To use this file, add this to your .emacs, uncommented : (load "cc-engine.elc") ;; And make text mode have auto-filling at column 72 (set-fill-column 72) (defun my-text-mode-hook () (auto-fill-mode) ) (add-hook 'text-mode-hook 'my-text-mode-hook) ;;(add-to-list 'load-path "/usr/share/emacs/site-lisp/kdesdk-scripts") ;;(require 'kde-emacs) ;;(setq kde-full-name "Alain Bertrand") ;;(setq kde-email "alainbe@free.fr") ;;source-header (defvar c++-source-extension-list '("c" "cc" "C" "cpp" "c++")) (defvar c++-header-extension-list '("h" "hh" "H" "hpp")) ;; Default extension for c++ header files. (defvar c++-default-header-ext "h") ;; Default extension for c++ source files. (defvar c++-default-source-ext "cpp") ;; Default regexp for c++ header files. (defvar c++-header-ext-regexp "\\.\\(hpp\\|h\\|\hh\\|H\\)$") ;; Default regexp for c++ source files. (defvar c++-source-ext-regexp "\\.\\(cpp\\|c\\|\cc\\|C\\)$") ;; Switches between source/header files (defun toggle-source-header() "Switches to the source buffer if currently in the header buffer and vice versa." (interactive) (let ((buf (current-buffer)) (name (file-name-nondirectory (buffer-file-name))) file offs) (setq offs (string-match c++-header-ext-regexp name)) (if offs (let ((lst c++-source-extension-list) (ok nil) ext) (setq file (substring name 0 offs)) (while (and lst (not ok)) (setq ext (car lst)) (if (file-exists-p (concat file "." ext)) (setq ok t)) (setq lst (cdr lst))) (if ok (find-file (concat file "." ext)))) (let () (setq offs (string-match c++-source-ext-regexp name)) (if offs (let ((lst c++-header-extension-list) (ok nil) ext) (setq file (substring name 0 offs)) (while (and lst (not ok)) (setq ext (car lst)) (if (file-exists-p (concat file "." ext)) (setq ok t)) (setq lst (cdr lst))) (if ok (find-file (concat file "." ext))))))))) ;; Compilation: Set new window height, never ask for compile command, save all files and sets new compile command. '(compilation-window-height 10) '(compilation-read-command nil) '(compilation-ask-about-save nil) '(compile-command "make -k") ;;mes options à moi (global-set-key [(f6)] 'toggle-source-header) (global-set-key [(f4)] 'compile) (global-set-key [(f11)] 'indent-region) (global-set-key [(f9)] 'ewd-insert-new-method) ;;(global-set-key [(tab)] 'agulbra-c++-tab) (setq auto-mode-alist (append '(("\\.h$" . c++-mode)) auto-mode-alist)) ;; Replace "yes or no" with y or n (defun yes-or-no-p (arg) "An alias for y-or-n-p, because I hate having to type 'yes' or 'no'." (y-or-n-p arg)) (add-to-list 'load-path "~/elisp") ;;(setq load-path (cons "~/deb/" load-path)) ;;(autoload 'dta-hook-up "desktopaid.elc" "Desktop Aid" t) ;;(dta-hook-up) ;;; (require 'windows) (win:startup-with-window) (define-key ctl-x-map "C" 'see-you-again) ;;; (autoload 'save-current-configuration "revive" "Save status" t) (autoload 'resume "revive" "Resume Emacs" t) (autoload 'wipe "revive" "Wipe Emacs" t) (define-key ctl-x-map "S" 'save-current-configuration) (define-key ctl-x-map "F" 'resume) (define-key ctl-x-map "K" 'wipe) (custom-set-variables ;; custom-set-variables was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. '(TeX-save-query nil) '(fill-column 72)) (custom-set-faces ;; custom-set-faces was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. ) ;;template module mostly used for auctex (require 'template) (template-initialize) (put 'upcase-region 'disabled nil) (defun indent-or-expand (arg) "Either indent according to mode, or expand the word preceding point." (interactive "*P") (if (and (or (bobp) (= ?w (char-syntax (char-before)))) (or (eobp) (not (= ?w (char-syntax (char-after)))))) (dabbrev-expand arg) (indent-according-to-mode))) (defun my-tab-fix () (local-set-key [tab] 'indent-or-expand)) (add-hook 'c-mode-hook 'my-tab-fix) (add-hook 'sh-mode-hook 'my-tab-fix) (add-hook 'emacs-lisp-mode-hook 'my-tab-fix)