help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: defining my own newline function


From: Ryan Krauss
Subject: Re: defining my own newline function
Date: Tue, 6 Nov 2007 08:25:02 -0600

On 11/6/07, Ryan Krauss <ryanlists@gmail.com> wrote:
> Sorry, I meant to cc the list as well.
>
> I can't  make 'M-: (current-local-mode)' do anything.  I assume you
> want me to press Alt-Shift-: (the shift is needed to make a colon
> rather than a semi-colon?).  When I do that, I prompted with
> Eval:
>
> so, I typed
> (current-local-mode)
>
> there and I get
>
> Debugger entered--Lisp error: (void-function current-local-mode)
>  (current-local-mode)
>  eval((current-local-mode))
>  eval-expression((current-local-mode) nil)
>  call-interactively(eval-expression)
>
>
> But the info line lists my major mode as the one being run.  The
> syntax highlighting is what I have defined, and my indent function is
> being used.  My local key map is also available, with an outdent
> function bound to backtab.  These keys don't work if I create a .txt
> file where my mode isn't running.  So, I think my mode is running and
> my local key map is happening with other keys.
>
> Ryan
>
> On 11/5/07, Drew Adams <drew.adams@oracle.com> wrote:
> > > (define-key pypoutline-mode-map "\C-j" 'pypoutline-newline-and-indent)
> > > (define-key pypoutline-mode-map [<return>] 'pypoutline-newline-and-indent)
> > > (define-key py-mode-map "\C-m" 'pypoutline-newline-and-indent)
> >
> > > but none of them seem to be working.  If I type C-h k and
> > > then hit return (in a buffer running my mode), I get:
> >
> > > RET (translated from <return>) runs the command newline
> >
> > > What am I doing wrong?  Is there something I need to add
> > > to the syntax table of my mode or somewhere else?
> >
> > Are you sure that you are in your mode and that your mode has your mode map
> > as its local map? What does `M-: (current-local-mode)' tell you?
> >
> > [BTW, it's generally better to use plain text, not HTML, for email to a
> > mailing list.]
> >
> >
>


So, I found the solution to my problem.  In trying to figure out what
key combination I needed to bind in my local map, I copied and pasted
from python-mode:

(define-key py-mode-map "\C-m" 'pypoutline-newline-and-indent)

I changed the name of the function, but not the name of the map.

Apparently, "\C-m" is the right one for my settings, but I forgot to
change which mode I wanted that key mapped in.  I discovered this when
I got strange behavior while trying to edit a python file.  Changing
the last line to

(define-key pypoutline-mode-map "\C-m" 'pypoutline-newline-and-indent)

fixed my issue.

Ryan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]