Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: Starting in c-set-style linux

1 view
Skip to first unread message

steve

unread,
Jul 17, 2021, 10:36:56 PM7/17/21
to
"Jesse B." <jakl...@adelphia.net> writes:

> I'm new to emacs, and I was wondering what I need to do in order to start
> emacs in linux mode with out have to "M-x c-set-style linux" every time I
> start emacs. I've looked all over the web and can't find anything on the
> subject. If anyone can point me in the right direction I'd be very greatful.


I saw your message a couple of days ago...

I have been using this for years, it is probably out of date.
This is the basic idea but it causes a problem (who would have thought).


(require 'cc-mode)
(c-set-style 'gnu")


You need to call the function every time you visit a c buffer. Emacs has
``hook'' functions to help.

Here is what I have been using. It seems to work.


;;; BOF dot-emacs

(eval-when-compile
;; this keeps the compiler happy
(require 'newcomment)
(require 'cc-mode))

(defun si:c-mode-hook ()
;; this is the hook functions
(require 'newcomment)
(setq comment-continue "**"
comment-style 'multi-line)
(setq c-progress-interval 3
c-block-comment-prefix "** "
c-tab-always-indent t
c-echo-syntactic-information-p nil)
(define-key c-mode-map "\r" 'newline-and-indent)
(setq c-indent-comments-syntactically-p t)
(c-set-style "gnu")
)

(add-to-list 'c-mode-hook 'si:c-mode-hook)

;;; EOF dot-emacs

When c-mode is started emacs calls every function in the list
`c-mode-hook' adding a custom function that gets called on specific
occastions is very common in lisp. there is usually a load time hook and
exit hook, etc...

Also, when in C-mode you can use [\C-C .] - set current c style.

The info pages cover c-mode very well. The same mode that is used for C
is also used for C++, java, etc...

with a grain of salt, it is getting late...
0 new messages