comp.emacs
[Top] [All Lists]

Problem Changing Return/Enter Keymapping with longlines-mode Enabled

Subject: Problem Changing Return/Enter Keymapping with longlines-mode Enabled
From: Bryan Kyle
Date: Sun, 17 Aug 2008 22:25:51 -0700 PDT
Newsgroups: comp.emacs

Hi All,

I've been working on writing an auto-indenting function for markdown-
mode but I'm running into problems when longlines-mode is enabled.

Below is the code for the function.  It's executed whenever the return/
enter key is pressed.  The idea is that the newly created line will be
indented to the same level as the previous line.  I've stepped through
the code as it's executing and all appears well.  It seems that the
code executed from longlines-mode, presumably in the post-command-hook
is removing the new line character.

(defun markdown-enter-key ()
  (interactive)
  (let (indent)
        (if markdown-indent-on-enter
                (setq indent
                          (save-excursion
                                (goto-char (point-at-bol))
                                (if (re-search-forward "^\s" (point-at-eol) t) 
t))))
        (insert "\n")
        (if indent (funcall indent-line-function))))

The code is attached to the key map as follows:

(define-key markdown-mode-map "\C-m" 'markdown-enter-key)

Has anyone run into a similar problem?  Am I doing something
completely wrong? Any help is greatly appreciated.

Thanks,
Bryan

<Prev in Thread] Current Thread [Next in Thread>
  • Problem Changing Return/Enter Keymapping with longlines-mode Enabled, Bryan Kyle <=
Privacy Policy