all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* a beginner's emacs troubles
@ 2007-07-29 22:48 f33ldead
  2007-07-30  0:08 ` roodwriter
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: f33ldead @ 2007-07-29 22:48 UTC (permalink / raw)
  To: help-gnu-emacs

Hi,

I have recently started using emacs, and I have come across with some
annoying problems with emacs. I hope someone can help with them:


    * I can't get auto-indentation working. When I open an empty file
and press tab, then press enter, the second line is not indented, the
cursor is at the beginning of the line.
    * I want line-by-line scrolling. When I move the cursor at the
bottom of the screen and press down, emacs scrolls many lines, rather
than a single line.
    * There's something strange with the way tab works in emacs. In cc
mode, I write a few letter then press and nothing happens! I'm not
allowed to put tabs anywhere on the file! I also tried editing an
empty file and I had no means of getting tab work!!! I just want my
tabs back!
    * And no spaces, only tabs!

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

* Re: a beginner's emacs troubles
  2007-07-29 22:48 a beginner's emacs troubles f33ldead
@ 2007-07-30  0:08 ` roodwriter
  2007-07-30  1:48 ` Daniel Leidisch
  2007-07-30  8:30 ` Mathias Häbich
  2 siblings, 0 replies; 15+ messages in thread
From: roodwriter @ 2007-07-30  0:08 UTC (permalink / raw)
  To: help-gnu-emacs

"f33ldead@gmail.com" <f33ldead@gmail.com> writes:

> Hi,
> 
> I have recently started using emacs, and I have come across with some
> annoying problems with emacs. I hope someone can help with them:
> 
> 
>     * I can't get auto-indentation working. When I open an empty file
> and press tab, then press enter, the second line is not indented, the
> cursor is at the beginning of the line.
>     * I want line-by-line scrolling. When I move the cursor at the
> bottom of the screen and press down, emacs scrolls many lines, rather
> than a single line.
>     * There's something strange with the way tab works in emacs. In cc
> mode, I write a few letter then press and nothing happens! I'm not
> allowed to put tabs anywhere on the file! I also tried editing an
> empty file and I had no means of getting tab work!!! I just want my
> tabs back!
>     * And no spaces, only tabs!
> 

I'm not sure how basic of a question you're asking.

I'm wondering if you're typing in the scratch buffer. You'll need to
switch to a text or programming mode that fits what you're trying to
do.

Need a little more information to be of help.

--Rod
______________________
Author of "Linux for Non-Geeks--Clear-eyed Answers for Practical
Consumers" and "Boring Stories from Uncle Rod." To reply by e-mail
take the second "o" out of the e-mail address.

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

* Re: a beginner's emacs troubles
  2007-07-29 22:48 a beginner's emacs troubles f33ldead
  2007-07-30  0:08 ` roodwriter
@ 2007-07-30  1:48 ` Daniel Leidisch
  2007-07-30  4:10   ` Tyler Smith
  2007-07-30  8:30 ` Mathias Häbich
  2 siblings, 1 reply; 15+ messages in thread
From: Daniel Leidisch @ 2007-07-30  1:48 UTC (permalink / raw)
  To: help-gnu-emacs

"f33ldead@gmail.com" <f33ldead@gmail.com> writes:

>     * I want line-by-line scrolling. When I move the cursor at the
> bottom of the screen and press down, emacs scrolls many lines, rather
> than a single line.

,----[ C-h v scroll-step RET ]
| scroll-step is a variable defined in `C source code'.
| Its value is 1
| 
| 
| Documentation:
| *The number of lines to try scrolling a window by when point moves out.
| If that fails to bring point back on frame, point is centered instead.
| If this is zero, point is always centered after it moves off frame.
| If you want scrolling to always be a line at a time, you should set
| `scroll-conservatively' to a large value rather than set this to 1.
| 
| You can customize this variable.
`----

I have (setq scroll-step 1) in my .emacs.

Regards,

dhl

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

* Re: a beginner's emacs troubles
  2007-07-30  1:48 ` Daniel Leidisch
@ 2007-07-30  4:10   ` Tyler Smith
  2007-07-30  6:18     ` f33ldead
  2007-07-30  7:56     ` Daniel Leidisch
  0 siblings, 2 replies; 15+ messages in thread
From: Tyler Smith @ 2007-07-30  4:10 UTC (permalink / raw)
  To: help-gnu-emacs

On 2007-07-30, Daniel Leidisch <news@leidisch.net> wrote:
> "f33ldead@gmail.com" <f33ldead@gmail.com> writes:
>
>>     * I want line-by-line scrolling. When I move the cursor at the
>> bottom of the screen and press down, emacs scrolls many lines, rather
>> than a single line.
>
> ,----[ C-h v scroll-step RET ]
>| scroll-step is a variable defined in `C source code'.
>| Its value is 1
>| 
>| 
>| Documentation:
>| *The number of lines to try scrolling a window by when point moves out.
>| If that fails to bring point back on frame, point is centered instead.
>| If this is zero, point is always centered after it moves off frame.
>| If you want scrolling to always be a line at a time, you should set
>| `scroll-conservatively' to a large value rather than set this to 1.
>| 
>| You can customize this variable.
> `----
>
> I have (setq scroll-step 1) in my .emacs.
>

And if you read back over the documentation you've just quoted, you'll
see that you should probably also have something like

(scroll-conservatively 50)

in your .emacs as well, if you want to scroll one line at a time ;)

Tyler

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

* Re: a beginner's emacs troubles
  2007-07-30  4:10   ` Tyler Smith
@ 2007-07-30  6:18     ` f33ldead
  2007-07-30  7:56     ` Daniel Leidisch
  1 sibling, 0 replies; 15+ messages in thread
From: f33ldead @ 2007-07-30  6:18 UTC (permalink / raw)
  To: help-gnu-emacs

On Jul 30, 7:10 am, Tyler Smith <tyler.sm...@mail.mcgill.ca> wrote:
> > I have (setq scroll-step 1) in my .emacs.
>
> And if you read back over the documentation you've just quoted, you'll
> see that you should probably also have something like
>
> (scroll-conservatively 50)
>
> in your .emacs as well, if you want to scroll one line at a time ;)
>
> Tyler

Thanks for the replies! I've added following to my .emacs and it's
working just fine!

(setq scroll-step 1)
(setq scroll-conservatively 50)


> I'm not sure how basic of a question you're asking.
>
> I'm wondering if you're typing in the scratch buffer. You'll need to
> switch to a text or programming mode that fits what you're trying to
> do.
>
> Need a little more information to be of help.
>
> --Rod

Ups. I'm sorry, it was indeed scratch buffer. I can type tabs freely
in text mode, but not in C mode. What happens in C mode is really
weird. I type the following line:

int main()

I move the cursor on a character in this line, then press tab, and...
nothing happens.

By the way, I've solved the auto-indent problem by adding this to
my .emacs

(global-set-key (kbd "\r")  'newline-and-indent)

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

* Re: a beginner's emacs troubles
  2007-07-30  4:10   ` Tyler Smith
  2007-07-30  6:18     ` f33ldead
@ 2007-07-30  7:56     ` Daniel Leidisch
  1 sibling, 0 replies; 15+ messages in thread
From: Daniel Leidisch @ 2007-07-30  7:56 UTC (permalink / raw)
  To: help-gnu-emacs

Tyler Smith <tyler.smith@mail.mcgill.ca> writes:

> And if you read back over the documentation you've just quoted, you'll
> see that you should probably also have something like
>
> (scroll-conservatively 50)
>
> in your .emacs as well, if you want to scroll one line at a time ;)

Thanks for the correction. Actually, that's in my .emacs, too, but
I forgot about it. Really should have read what I've quoted ;)

Regards

dhl

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

* Re: a beginner's emacs troubles
  2007-07-29 22:48 a beginner's emacs troubles f33ldead
  2007-07-30  0:08 ` roodwriter
  2007-07-30  1:48 ` Daniel Leidisch
@ 2007-07-30  8:30 ` Mathias Häbich
  2007-07-30 12:22   ` Tyler Smith
  2 siblings, 1 reply; 15+ messages in thread
From: Mathias Häbich @ 2007-07-30  8:30 UTC (permalink / raw)
  To: help-gnu-emacs

f33ldead@gmail.com wrote:

>     * There's something strange with the way tab works in emacs. In cc
> mode, I write a few letter then press and nothing happens! I'm not
> allowed to put tabs anywhere on the file! I also tried editing an
> empty file and I had no means of getting tab work!!! I just want my
> tabs back!

It's not strange at all if you know what function the TAB key is bound 
to. In cc-mode, it is c-indent-command, and in lisp-mode (the scratch 
buffer's mode) it is lisp-indent-line. (C-h k TAB tells you this - very 
useful!)

What you want is probably tab-to-tab-stop, which is usually bound to M-i.

Regards,
Mathias

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

* Re: a beginner's emacs troubles
  2007-07-30  8:30 ` Mathias Häbich
@ 2007-07-30 12:22   ` Tyler Smith
  2007-07-31  1:02     ` f33ldead
  0 siblings, 1 reply; 15+ messages in thread
From: Tyler Smith @ 2007-07-30 12:22 UTC (permalink / raw)
  To: help-gnu-emacs

On 2007-07-30, Mathias Häbich <m.haebich@gmx.de> wrote:
> f33ldead@gmail.com wrote:
>
>>     * There's something strange with the way tab works in emacs. In cc
>> mode, I write a few letter then press and nothing happens! I'm not
>> allowed to put tabs anywhere on the file! I also tried editing an
>> empty file and I had no means of getting tab work!!! I just want my
>> tabs back!
>
> It's not strange at all if you know what function the TAB key is bound 
> to. In cc-mode, it is c-indent-command, and in lisp-mode (the scratch 
> buffer's mode) it is lisp-indent-line. (C-h k TAB tells you this - very 
> useful!)
>
> What you want is probably tab-to-tab-stop, which is usually bound to M-i.
>

Before you start using tab-to-tab-stop, it might be worthwhile to play
around with how the regular tab/c-indent-command works. What it does
is automatically indent the current line according to a set of rules.
The result is that it provides an easy way to keep your code
consistently indented. It will know when you've entered a new code
block, loop, or conditional, and indent appropriately. If you don't
like the way it indents, there are way to customize the rules. I know
it's awkward at first, but I really like it now. It can actually be
handy in spotting syntax errors - a missing brace or semi-colon will
produce obviously incorrect indentation, alerting you that you've left
something out.

My 2 cents,

Tyler

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

* Re: a beginner's emacs troubles
  2007-07-30 12:22   ` Tyler Smith
@ 2007-07-31  1:02     ` f33ldead
  2007-07-31  6:23       ` Kevin Rodgers
  2007-07-31 16:25       ` don provan
  0 siblings, 2 replies; 15+ messages in thread
From: f33ldead @ 2007-07-31  1:02 UTC (permalink / raw)
  To: help-gnu-emacs

I have something similar:

#define SOMETHING      0x43
#define SOMETHING_ELSE      0x12
#define ANYWAY   0x56

I need tabs between the defined term and it's value so that it'll be
indented nicely. And I just can't do it. That's what I was actually
referring to. I think it's a bad idea to decide where tabs _can_ to
for an editor.

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

* Re: a beginner's emacs troubles
  2007-07-31  1:02     ` f33ldead
@ 2007-07-31  6:23       ` Kevin Rodgers
  2007-07-31 16:25       ` don provan
  1 sibling, 0 replies; 15+ messages in thread
From: Kevin Rodgers @ 2007-07-31  6:23 UTC (permalink / raw)
  To: help-gnu-emacs

f33ldead@gmail.com wrote:
> I have something similar:
> 
> #define SOMETHING      0x43
> #define SOMETHING_ELSE      0x12
> #define ANYWAY   0x56
> 
> I need tabs between the defined term and it's value so that it'll be
> indented nicely. And I just can't do it. That's what I was actually
> referring to. I think it's a bad idea to decide where tabs _can_ to
> for an editor.

You are assuming that pressing the tab key inserts a tab character,
but actually the tab key is bound to a command (like any other key).
If you want to insert a tab character, use `C-q TAB'.

-- 
Kevin Rodgers
Denver, Colorado, USA

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

* Re: a beginner's emacs troubles
  2007-07-31  1:02     ` f33ldead
  2007-07-31  6:23       ` Kevin Rodgers
@ 2007-07-31 16:25       ` don provan
  2007-07-31 20:13         ` f33ldead
  1 sibling, 1 reply; 15+ messages in thread
From: don provan @ 2007-07-31 16:25 UTC (permalink / raw)
  To: help-gnu-emacs

"f33ldead@gmail.com" <f33ldead@gmail.com> writes:

> I have something similar:
>
> #define SOMETHING      0x43
> #define SOMETHING_ELSE      0x12
> #define ANYWAY   0x56
>
> I need tabs between the defined term and it's value so that it'll be
> indented nicely. And I just can't do it. That's what I was actually
> referring to. I think it's a bad idea to decide where tabs _can_ to
> for an editor.

Yes, perfectly reasonable, but for some reason not the default
behavior. You're looking for

          (setq c-tab-always-indent nil)

This keeps tab performing the indentation feature you've been hearing
about when it's typed near the beginning of the line, but it inserts a
normal tab when typed in the middle of a line.

Also, it sounds like you'll want to hear that meta-I by default is
mapped to "tab-to-tab-stop" (i.e., what you expect tab to do), so
you might want to try playing around with the tab key set to the
indentation function and getting in the habit of using meta-I when you
really want a tab.

(It turns out that there's actually a emacs extension you can track
down that solves this problem explicitly, allowing you to line up
columns like this neatly on command. Alas, I've never felt the need to
try them, so I can't tell you what they are.)

Similarly, you mapped the enter key to newline-and-indent, but you
might be interested to know that control-J is naturally mapped to that
function. You might want to try leaving enter for the natrual
character the unindented newline and get used to using ^J for the
function you expected on Enter.

You can customize emacs all you want, of course, but I find it easier
to stick to the default mappings even when they aren't always on the
keys I expect them to be on. I do this for several reasons, but the
most convincing is that when I stick to the default mappings, 9 times
out of 10 I discover that there is, in fact, some advantage to the way
the keys are mapped out of the box.

-don provan

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

* Re: a beginner's emacs troubles
  2007-07-31 16:25       ` don provan
@ 2007-07-31 20:13         ` f33ldead
  2007-07-31 22:45           ` Drew Adams
       [not found]           ` <mailman.4175.1185921962.32220.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 15+ messages in thread
From: f33ldead @ 2007-07-31 20:13 UTC (permalink / raw)
  To: help-gnu-emacs

Thanks a lot for replies. I have two problems now. First is as
follows.

> Yes, perfectly reasonable, but for some reason not the default
> behavior. You're looking for
>
>           (setq c-tab-always-indent nil)

Well, I think I'll prefer ^J as the "default" enter anyway. Having set
it, I've noticed this thing: if you type a '{' then execute newline-
and-indent, it indent one tabs further!

if(a)
   {

   }

Well, this's not my convention, so I tried switching to K&R mode, but
nothing has changed.

My second problem is this: I press tab, emacs inserts a tab character,
then I press backspace, in hopes that emacs will delete tab character,
but instead it goes back one-character space, and leaves many spaces
in place of tab!

I'm really fed up with emacs' understanding of tabs :/

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

* RE: a beginner's emacs troubles
  2007-07-31 20:13         ` f33ldead
@ 2007-07-31 22:45           ` Drew Adams
       [not found]           ` <mailman.4175.1185921962.32220.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 15+ messages in thread
From: Drew Adams @ 2007-07-31 22:45 UTC (permalink / raw)
  To: f33ldead, help-gnu-emacs

> My second problem is this: I press tab, emacs inserts a tab character,
> then I press backspace, in hopes that emacs will delete tab character,
> but instead it goes back one-character space, and leaves many spaces
> in place of tab!

See user option `backward-delete-char-untabify-method'.

> I'm really fed up with emacs' understanding of tabs :/

Just a suggestion: It's your understanding of TAB in Emacs that you need to
improve, if you want to be able to use Emacs to your advantage. ;-)

Keep in mind too that TAB behavior is one of those (many) things that people
have very different opinions about, and first opinions about it often change
as someone uses Emacs more. The manual should help, and you can search for
`tab' on Emacs Wiki: http://www.emacswiki.org/cgi-bin/wiki?search=tab.

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

* Re: a beginner's emacs troubles
       [not found]           ` <mailman.4175.1185921962.32220.help-gnu-emacs@gnu.org>
@ 2007-08-01  1:41             ` f33ldead
  2007-08-01  8:59               ` Alan Mackenzie
  0 siblings, 1 reply; 15+ messages in thread
From: f33ldead @ 2007-08-01  1:41 UTC (permalink / raw)
  To: help-gnu-emacs

On Aug 1, 1:45 am, "Drew Adams" <drew.ad...@oracle.com> wrote:

> See user option `backward-delete-char-untabify-method'.
>


OK, my final tab setting in my .emacs is as follows:

(setq c-tab-always-indent nil)
(global-set-key (kbd "TAB") 'self-insert-command)
(setq-default tab-width 8
              standard-indent 8
              indent-tabs-mode t)
(setq backward-delete-char-untabify-method nil)

Now, in c-mode, in a function, I press tab, and it inserts a tab. I
start typing "exec", it's still fine, then as I open a paranthesis to
write the function call, everything's ruined again!

> Just a suggestion: It's your understanding of TAB in Emacs that you need to
> improve, if you want to be able to use Emacs to your advantage. ;-)

Well, it's a habit of 10 years by now. It's not easy to change habits
easily ;) What I expect is simply the behavior of nano; I'm shocked
that it's such a struggle to achieve it in emacs.

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

* Re: a beginner's emacs troubles
  2007-08-01  1:41             ` f33ldead
@ 2007-08-01  8:59               ` Alan Mackenzie
  0 siblings, 0 replies; 15+ messages in thread
From: Alan Mackenzie @ 2007-08-01  8:59 UTC (permalink / raw)
  To: f33ldead@gmail.com; +Cc: help-gnu-emacs

On Wed, Aug 01, 2007 at 01:41:35AM -0000, f33ldead@gmail.com wrote:
> On Aug 1, 1:45 am, "Drew Adams" <drew.ad...@oracle.com> wrote:

> > See user option `backward-delete-char-untabify-method'.

> OK, my final tab setting in my .emacs is as follows:

> (setq c-tab-always-indent nil)
> (global-set-key (kbd "TAB") 'self-insert-command)
> (setq-default tab-width 8
>               standard-indent 8
>               indent-tabs-mode t)
> (setq backward-delete-char-untabify-method nil)

> Now, in c-mode, in a function, I press tab, and it inserts a tab. I
> start typing "exec", it's still fine, then as I open a paranthesis to
> write the function call, everything's ruined again!

This is called "electric indentation", and you can switch it off by C-c
C-l, but you have to do this in each buffer separately.  To switch it off
by default, put this fairly early on in your emacs:

    (setq-default c-electric-flag nil)

You would have seen this in the CC Mode manual if you'd've read the page
"Getting Started" ;-).  Please spend a couple of hours browsing through
this manual.  It was extensively revised for Emacs 22.1.  Read the
earlier pages, and have a quick flick through the "FAQ" near the end.

> > Just a suggestion: It's your understanding of TAB in Emacs that you
> > need to improve, if you want to be able to use Emacs to your
> > advantage. ;-)

> Well, it's a habit of 10 years by now. It's not easy to change habits
> easily ;) What I expect is simply the behavior of nano; I'm shocked
> that it's such a struggle to achieve it in emacs.

Good!  If you're shocked, it shows that your prejudices, preconceptions
and so on are being questioned.  That's to say, you're getting a chance
to learn, to grow, to broaden your horizons, become a more mature, better
balanced person.  ;-)  If, after trying Emacs out for long enough (at
least a few weeks), you still can't get along with Emacs's <TAB>, then
it's probably not the right editor for you, and there's nothing wrong
with that.

Emacs is a supremely easy and productive tool to use.  However, it's an
utter bastard to learn.  We've all had to go through this process.

The thinking behind indentation being done by the <TAB> key, or when you
type a paren, is that it saves you time.  Typing lots of spaces at the
beginning of lines is BORING and TEDIOUS and distracts you from the real
business of writing your program.  Lining up your text correctly is also
BORING and TEDIOUS.  That's what your computer's there to do!

Right at the moment, you feel that you're out of control, and the text is
jumping about all over the place, and you can't even insert a simple tab
character, and you're probably screeming with rage and frustration.  So,
remap <TAB> to insert a tab, switch off the electricity and so on.  But
as soon as you feel you've got some semblance of control back, you should
gradually experiment with these features, switching them back on one by
one.  Spend some days and weeks playing with CC Mode's configuration
(hint: read the CC Mode manual - it has a page "Sample .emacs file" to
help you ;-).

Remember that Emacs's features weren't put in to confound new users; they
have been refined over over twenty years by the same people who actually
use them, to be as efficient and productive as possible, and some of
these people are amongst the smartest on the planet.

Once you've got used to it, you'll never ever want to use nano again,
just as a car driver wouldn't want to go back to using a child's pedal
car.

-- 
Alan Mackenzie (Ittersbach, Germany).

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

end of thread, other threads:[~2007-08-01  8:59 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-29 22:48 a beginner's emacs troubles f33ldead
2007-07-30  0:08 ` roodwriter
2007-07-30  1:48 ` Daniel Leidisch
2007-07-30  4:10   ` Tyler Smith
2007-07-30  6:18     ` f33ldead
2007-07-30  7:56     ` Daniel Leidisch
2007-07-30  8:30 ` Mathias Häbich
2007-07-30 12:22   ` Tyler Smith
2007-07-31  1:02     ` f33ldead
2007-07-31  6:23       ` Kevin Rodgers
2007-07-31 16:25       ` don provan
2007-07-31 20:13         ` f33ldead
2007-07-31 22:45           ` Drew Adams
     [not found]           ` <mailman.4175.1185921962.32220.help-gnu-emacs@gnu.org>
2007-08-01  1:41             ` f33ldead
2007-08-01  8:59               ` Alan Mackenzie

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.