all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* "Tab-fix"
@ 2008-07-22  6:22 denebet
  2008-07-22  6:54 ` "Tab-fix" Pascal J. Bourguignon
  0 siblings, 1 reply; 3+ messages in thread
From: denebet @ 2008-07-22  6:22 UTC (permalink / raw
  To: help-gnu-emacs

I have put the stuff found at
<http://www.emacsblog.org/2007/03/12/tab-completion-everywhere/>
 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)



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: "Tab-fix"
  2008-07-22  6:22 "Tab-fix" denebet
@ 2008-07-22  6:54 ` Pascal J. Bourguignon
  2008-07-22 10:11   ` "Tab-fix" denebet
  0 siblings, 1 reply; 3+ messages in thread
From: Pascal J. Bourguignon @ 2008-07-22  6:54 UTC (permalink / raw
  To: help-gnu-emacs

denebet <denebet@lechebet.bzh> writes:

> I have put the stuff found at
> <http://www.emacsblog.org/2007/03/12/tab-completion-everywhere/>
>  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 ?

In a *.cpp buffer, type: M-: major-mode RET
What do you get?

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
The rule for today:
Touch my tail, I shred your hand.
New rule tomorrow.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: "Tab-fix"
  2008-07-22  6:54 ` "Tab-fix" Pascal J. Bourguignon
@ 2008-07-22 10:11   ` denebet
  0 siblings, 0 replies; 3+ messages in thread
From: denebet @ 2008-07-22 10:11 UTC (permalink / raw
  To: help-gnu-emacs

Pascal J. Bourguignon wrote:

> denebet <denebet@lechebet.bzh> writes:
>> (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 ?
> 
> In a *.cpp buffer, type: M-: major-mode RET
> What do you get?
> 
c++-mode.

Thanks, fixed my .emacs.
Actually I had tried 
(add-hook 'cc-mode-hook          'my-tab-fix) before sending my message.

Regards,

Alain


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-07-22 10:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-22  6:22 "Tab-fix" denebet
2008-07-22  6:54 ` "Tab-fix" Pascal J. Bourguignon
2008-07-22 10:11   ` "Tab-fix" denebet

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.