* tab / indent / spaces / modes
@ 2004-01-27 11:54 Richard Chamberlain
2004-01-27 14:07 ` kgold
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Richard Chamberlain @ 2004-01-27 11:54 UTC (permalink / raw)
Hello,
After getting a bit sick of my current editor I decided I should
really learn emacs. I'm fairly ok with the basics of editing. However
I'm totally lost when it comes to configuration.
I'm using php-mode and I want to be able to switch off the indentation
mode, because what I want for formatting and what php-mode suggests is
different.
So I want the tab key to actually insert a tab, a tab to cover four
spaces but actually be a tab rather than spaces.
I've tried fiddling with C Tab Always Indent, C Insert Tab Function, C
Syntatic Indentation because I believe they are being used in
php-mode. But I can't quite get it.
Also is it possible to switch off wrapping so that I have to scroll
right if I want to see the rest of the line? Some of the html tends to
be in a long single line and I find it difficult to read like it is.
I've tried reading the archives but I get a bit lost in some of the
responses.
Can someone tell me which settings I need in terms that a complete
emacs newbie can get.
Many thanks,
Richard
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: tab / indent / spaces / modes
2004-01-27 11:54 tab / indent / spaces / modes Richard Chamberlain
@ 2004-01-27 14:07 ` kgold
2004-01-31 0:51 ` Emory Smith
[not found] ` <mailman.1647.1075510308.928.help-gnu-emacs@gnu.org>
2004-01-27 20:31 ` tab / indent / spaces / modes Peter Lee
2004-01-28 11:24 ` Richard Chamberlain
2 siblings, 2 replies; 6+ messages in thread
From: kgold @ 2004-01-27 14:07 UTC (permalink / raw)
richard@sunsetandlabrea.com (Richard Chamberlain) writes:
>
> After getting a bit sick of my current editor I decided I should
> really learn emacs. I'm fairly ok with the basics of editing. However
> I'm totally lost when it comes to configuration.
>
> I'm using php-mode and I want to be able to switch off the indentation
> mode, because what I want for formatting and what php-mode suggests is
> different.
This might not be the answer you want but ...
Rather than turn off indentation, why not just customize it to format
the way you like? In emacs, nearly everything is customizable.
I use emacs for mostly C-like programming languages. I've found that
the automatic indentation is a big time saver, both because it saves
typing and because it finds missing punctuation.
It's great when you cut and paste, and the pasted code is automaticly
reformatted. Or you can select sections of code written by
someone else and reformat it.
Since you're new to emacs, I suggest you give it a chance before you
start turning pieces of it off.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: tab / indent / spaces / modes
2004-01-27 14:07 ` kgold
@ 2004-01-31 0:51 ` Emory Smith
[not found] ` <mailman.1647.1075510308.928.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 6+ messages in thread
From: Emory Smith @ 2004-01-31 0:51 UTC (permalink / raw)
Cc: help-gnu-emacs
On Jan 27, 2004, at 2:07 PM, kgold wrote:
> richard@sunsetandlabrea.com (Richard Chamberlain) writes:
>>
>> I'm using php-mode and I want to be able to switch off the indentation
>> mode, because what I want for formatting and what php-mode suggests is
>> different.
>
> Rather than turn off indentation, why not just customize it to format
> the way you like? In emacs, nearly everything is customizable.
>
im also using php and having trouble with indentation. i would like to
keep the indentation on and customize it (as kgold suggested).
my main problem is with comments (// or /**/). php-mode seems to not
recognize them as comments and gives me doubly indented line after i
use one (even if they are after the semicolon.
so i was wondering how i might find out (and change) what character
sequences php-mode recognizes as comment delimiters and what it does
when it recognizes one.
thanks
^ permalink raw reply [flat|nested] 6+ messages in thread
[parent not found: <mailman.1647.1075510308.928.help-gnu-emacs@gnu.org>]
* Re: tab / indent / spaces / modes [PHP coding]
[not found] ` <mailman.1647.1075510308.928.help-gnu-emacs@gnu.org>
@ 2004-02-08 10:27 ` Jari Aalto+mail.tpu
0 siblings, 0 replies; 6+ messages in thread
From: Jari Aalto+mail.tpu @ 2004-02-08 10:27 UTC (permalink / raw)
* Fri 2004-01-30 Emory Smith <emory.smith <AT> mac.com> gnu.emacs.help
* <http://groups.google.com/groups?oi=djq&as_umsgid=%3Cmailman.1647.1075510308.928.help-gnu-emacs@gnu.org>
| On Jan 27, 2004, at 2:07 PM, kgold wrote:
|
| > richard <AT> sunsetandlabrea.com (Richard Chamberlain) writes:
| >>
| >> I'm using php-mode and I want to be able to switch off the indentation
| >> mode, because what I want for formatting and what php-mode suggests is
| >> different.
| >
| > Rather than turn off indentation, why not just customize it to format
| > the way you like? In emacs, nearly everything is customizable.
| >
|
| im also using php and having trouble with indentation. i would like
| to keep the indentation on and customize it (as kgold suggested).
|
| my main problem is with comments (// or /**/). php-mode seems to not
| recognize them as comments and gives me doubly indented line after i
| use one (even if they are after the semicolon.
|
| so i was wondering how i might find out (and change) what character
| sequences php-mode recognizes as comment delimiters and what it does
| when it recognizes one.
I use this something likes this for PHP (This is only part of the
setup). Hope it gives some ideas. PHP uses cc-mode, so the indentation
must be defined there.
Jari
(require 'cl)
(setq tab-stop-list
(let ((i 4) list)
(while (< i 80)
(setq list (cons i list))
(setq i (+ i 4)))
(reverse list)))
(defun my-tmp-set-tab-key-to-run-4-spaces (map)
"Define TAB key to run 4 spaces."
(setq indent-tabs-mode nil) ;; do NOT use tab characters
(define-key map "\t" 'tab-to-tab-stop))
(defun my-tmp-c-coding-setup ()
"Define C and C++ defaul coding style."
;; See cc-compat.el
(setq c-basic-offset 4) ;; Default was 2
(setq c-indent-level 4) ;; Default was 2
(setq c-label-offset 0) ;; Default was -2
(setq c-continued-statement-offset 0) ;; Default was 2
;; See cc-vars.el / C-h v c-offsets-alist
(c-set-offset 'comment-intro '(c-lineup-comment))
(c-set-offset 'topmost-intro-cont '+) ;; Was c-lineup-topmost-intro-cont
(c-set-offset 'arglist-intro '+) ;; Default was +
(c-set-offset 'arglist-close 0) ;; Default was +
;; (c-set-offset 'arglist-cont-nonempty '(c-lineup-arglist))
(c-set-offset 'access-label 0) ;; Default was -
(c-set-offset 'label 0) ;; Default was 2
(c-set-offset 'defun-block-intro '+)
(c-set-offset 'statement-cont 0) ;; Default was +
(c-set-offset 'substatement-open 0)
(c-set-offset 'statement-block-intro '+))
(defun my-tmp-c-mode-setup ()
"Prepare C and C++ mode."
(dolist (hook '(c++-mode-hook
c-mode-hook))
(add-hook hook 'my-tmp-c-coding-setup)))
(my-tmp-c-mode-setup)
;; Status: 3rd party package http://sourceforge.net/projects/php-mode/
;;
;; Emacs does not have built-in PHP coding support
;; This mode uses C mode
(defun my-tmp-php-compile-command ()
"Set default compile command."
(when (and (string-match "php" (symbol-name major-mode))
(executable-find "php"))
(setq compile-command "php ")))
(defun my-tmp-php-mode-turn-on-settings ()
"When ´php-mode' is turned on, run these settings."
(setq c-auto-newline t) ;; See M-x c-toggle-auto-state
;; Cancel CC mode's electric keys
(define-key php-mode-map "/" 'self-insert-command)
(define-key php-mode-map "," 'self-insert-command)
(define-key php-mode-map ";" 'self-insert-command)
(define-key php-mode-map "(" 'self-insert-command)
(define-key php-mode-map ")" 'self-insert-command))
(defun my-tmp-php-mode ()
"Write PHP code."
(interactive)
(cond
((fboundp 'php-mode)
(let ((func 'php-mode))
(funcall func)))
((fboundp 'html-helper-mode)
(let ((func 'html-helper-mode))
(funcall func 1))
(my-tmp-set-tab-key-to-run-4-spaces (current-local-map)))
((fboundp 'html-mode)
(html-mode)
(my-tmp-set-tab-key-to-run-4-spaces (current-local-map)))
(t
(text-mode)))
(my-tmp-php-compile-command))
(defun my-tmp-php-mode-setup ()
"Install PHP support."
(pushnew '("\\.php[s34]?$" . my-tmp-php-mode) auto-mode-alist :test 'equal)
(cond
((or (fboundp 'php-mode)
(locate-library "php-mode"))
(autoload 'php-mode "php-mode" "" t)
(setq php-manual-url "http://www.php.net/manual/en/")
(add-hook 'php-mode-user-hook 'my-tmp-php-mode-turn-on-settings))))
(my-tmp-php-mode-setup)
--
http://tiny-tools.sourceforge.net/
Swatch @time http://www.mir.com.my/iTime/itime.htm
http://www.ryanthiessen.com/swatch/resources.htm
Use Licenses! http://www.linuxjournal.com/article.php?sid=6225
Which Licence? http://www.linuxjournal.com/article.php?sid=4825
OSI Licences http://www.opensource.org/licenses/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: tab / indent / spaces / modes
2004-01-27 11:54 tab / indent / spaces / modes Richard Chamberlain
2004-01-27 14:07 ` kgold
@ 2004-01-27 20:31 ` Peter Lee
2004-01-28 11:24 ` Richard Chamberlain
2 siblings, 0 replies; 6+ messages in thread
From: Peter Lee @ 2004-01-27 20:31 UTC (permalink / raw)
>>>> Richard Chamberlain writes:
Richard> I want to be able to switch off the indentation mode
(setq perl-tab-always-indent nil)
Richard> So I want the tab key to actually insert a tab, a tab to
Richard> cover four spaces but actually be a tab rather than
Richard> spaces.
(setq tab-always-indent nil)
(setq tab-stop-list '(4 8 12 16 20 24 28 32 36 40 44 48 52 56 60))
(setq tab-width 4)
(setq indent-tabs-mode nil)
Richard> Also is it possible to switch off wrapping so that I have
Richard> to scroll right if I want to see the rest of the line?
Richard> Some of the html tends to be in a long single line and I
Richard> find it difficult to read like it is.
(setq truncate-lines t)
I would put cursor over each of those variables I have above and type
'C-h v'. Read the docs on that var and set it how you like.
Once you have them to your liking install a hook in your init file to
set all those whenever perl mode is loaded. Mine looks like this:
(defun my-perl-mode-hook ()
(setq perl-indent-level 0)
(setq perl-brace-offset 4)
(setq perl-tab-always-indent nil))
(add-hook 'perl-mode-hook 'my-perl-mode-hook)
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: tab / indent / spaces / modes
2004-01-27 11:54 tab / indent / spaces / modes Richard Chamberlain
2004-01-27 14:07 ` kgold
2004-01-27 20:31 ` tab / indent / spaces / modes Peter Lee
@ 2004-01-28 11:24 ` Richard Chamberlain
2 siblings, 0 replies; 6+ messages in thread
From: Richard Chamberlain @ 2004-01-28 11:24 UTC (permalink / raw)
Many thanks for the replies.
I shall continue playing and see how I get on.
Cheers,
Richard
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2004-02-08 10:27 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-01-27 11:54 tab / indent / spaces / modes Richard Chamberlain
2004-01-27 14:07 ` kgold
2004-01-31 0:51 ` Emory Smith
[not found] ` <mailman.1647.1075510308.928.help-gnu-emacs@gnu.org>
2004-02-08 10:27 ` tab / indent / spaces / modes [PHP coding] Jari Aalto+mail.tpu
2004-01-27 20:31 ` tab / indent / spaces / modes Peter Lee
2004-01-28 11:24 ` Richard Chamberlain
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).