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

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

Strange behavior with major mode specific key bindings


From: Tim Johnson
Subject: Strange behavior with major mode specific key bindings
Date: Fri, 24 Apr 2020 14:20:41 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.1

I have customized a key binding for jinja2 mode.

;; In my init.el I have the following
(require 'jinja2-mode)
(require 'tj-mode-custom)
(add-to-list 'auto-mode-alist '("\\.html$" . jinja2-mode))
(add-hook 'jinja2-mode-hook 'tj-jinja2-mode-keys)

;; In  tj-mode-custom the following

(defun tj-jinja2-mode-keys ()
  "Bindings and for jinja2"
  (define-prefix-command 'jinja2-mode-map)
  (local-set-key (kbd "C-c") 'jinja2-mode-map)
  (define-key jinja2-mode-map "a" 'jinja2-close-tag))

If an .html file is loaded at emacs startup, the following key sequence:

C-c a

invokes jinja2-close-tag

BUT if I open an .html file that is on disk but not preloaded at startup, OR if I create a new .html file, the single character "a" will execute the same function.

In other words, now both "C-c a" and "a" are bound to 'jinja2-close-tag, clobbering 'insert-char

I can observe that the newly opened files are in jinja2 mode.

I do not have similar issues with elpy mode

I am using GNU Emacs 26.3 (build 1, x86_64-pc-linux-gnu, GTK+ Version 2.24.30)

On ubuntu 16.04

thanks


--
Tim
tj49.com




reply via email to

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