Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 04 Jun 2005 09:17:29 +0900
From:      JINMEI Tatuya / =?ISO-2022-JP?B?GyRCP0BMQEMjOkgbKEI=?= <jinmei@isl.rdc.toshiba.co.jp>
To:        "Li, Qing" <qing.li@bluecoat.com>
Cc:        freebsd-net@freebsd.org, Andre Oppermann <andre@freebsd.org>
Subject:   Re: issue with route
Message-ID:  <y7vis0vt1pi.wl%jinmei@isl.rdc.toshiba.co.jp>
In-Reply-To: <48D44BB27BDE3840BDF18E59CB169A5C012A51E0@bcs-mail3.internal.cacheflow.com>
References:  <48D44BB27BDE3840BDF18E59CB169A5C012A51E0@bcs-mail3.internal.cacheflow.com>

next in thread | previous in thread | raw e-mail | index | archive | help
(I'm afraid we're going to an off-topic.  If this message needs a
response, we should perhaps do that off-list.)

>>>>> On Fri, 3 Jun 2005 15:40:14 -0700, 
>>>>> "Li, Qing" <qing.li@bluecoat.com> said:

>> Are you perhaps asking for .emacs setting which conforms to this (the
>> four-space) style?

>     Yes, do you have one ?

I'm using this one.

					JINMEI, Tatuya
					Communication Platform Lab.
					Corporate R&D Center, Toshiba Corp.
					jinmei@isl.rdc.toshiba.co.jp

(add-hook 'c-mode-common-hook
	  (function
	   (lambda ()
	     (c-set-style "bsd")
	     (c-set-offset 'statement 'netbsd-knf-lineup-statement)
	     (c-set-offset 'arglist-intro 'netbsd-knf-lineup-arglist)
	     (c-set-offset 'arglist-cont 'netbsd-knf-lineup-arglist)
             (c-set-offset 'arglist-cont-nonempty 'netbsd-knf-lineup-arglist)
...;;(other personal settings)
)))

(defun netbsd-knf-lineup-arglist (langelem)
  (let ((syntax (car (c-guess-basic-syntax)))
	(langelem-col (c-langelem-col langelem t))
	(head)
	)
    (save-excursion
      (while (memq (car syntax)
		   '(arglist-cont-nonempty statement-cont
					   arglist-intro arglist-cont))
	(goto-char (cdr syntax))
	(setq syntax (car (c-guess-basic-syntax))))
      (if (eq (car syntax) 'statement)
	  (goto-char (netbsd-knf-statement-head)))
      (beginning-of-line)
      (skip-chars-forward " \t")
      (+ (- (current-column) langelem-col) (/ c-basic-offset 2)))))

(defun netbsd-knf-statement-head ()
  (let ((cp (point)))
    (save-excursion
      (backward-up-list 1)
      (cond ((netbsd-knf-after-for-loop-p (point))
	     (beginning-of-line)
	     (skip-chars-forward " \t")
	     (point))
	   (t cp)))))

(defun netbsd-knf-lineup-statement (langelem)
  (let ((syntax (car (c-guess-basic-syntax))))
    (cond ((and (cdr syntax)	;to handle (comment-intro) (statement . xx)
		(netbsd-knf-after-for-loop-p (cdr syntax)))
	   (save-excursion
	     (goto-char (cdr syntax))
	     (beginning-of-line)
	     (skip-chars-forward " \t")
	     (+ (- (current-column) (c-langelem-col langelem t))
		(/ c-basic-offset 2))))
	(t 0))))

(defun netbsd-knf-after-for-loop-p (pos)
  "True if POS is just after `for ('"
  (save-excursion
    (goto-char pos)
    (condition-case ()
	(progn (backward-word 1)
	       (looking-at "\\bfor ("))
      (beginning-of-buffer nil))))



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?y7vis0vt1pi.wl%jinmei>