all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Emacs keybindings according to file type
@ 2020-09-21  6:46 Christopher Dimech
  2020-09-21 14:16 ` Eli Zaretskii
  0 siblings, 1 reply; 11+ messages in thread
From: Christopher Dimech @ 2020-09-21  6:46 UTC (permalink / raw)
  To: Help Gnu Emacs


I want to set different keybinding according to the type of file I load
into a buffer. I wonder how I can do that.

In my .emacs file I have

; Loads texinfo Customisations
(setq texi--customs "/home/hagbard/swadmin/emacs/el/naiad/texi--custom.el")
(load texi--customs)

; Loads Fortran Customisations.
(setq fortran--customs "/home/hagbard/swadmin/emacs/el/naiad/fortran--custom.el")
(load fortran--customs)

; Adds Org Mode Custimisations
(setq org--customs "/home/hagbard/swadmin/emacs/el/naiad/org--custom.el")
(load org--customs)

Then in separate files I have commands for each language.

---------

I want to have keybinding for f1 and f2 to toggle between org-mode and texinfo-mode
when the file is a .texi

; Helps traverse a texinfo document using org-mode commands
; Sets Keybinding for switching between texinfo-mode and org-mode
; The Major Mode toggle is used for Syntax Highlighting
  (global-set-key [f1] (kbd "M-x org-mode"))
  (global-set-key [f2] (kbd "M-x texinfo-mode"))

And if I have a .f file, I want the keybinding for f90-mode
  (global-set-key [f1] (kbd "M-x org-mode"))
  (global-set-key [f2] (kbd "M-x f90-mode"))

-------

However, if one looks at the .emacs file, the keybindings that take effect is always of
the last file that is loaded, in this case being fortran--custom.el.  This means that if
I load a .texi file, the keybinding f2 will not change the buffer to texinfo-mode.

Regards
S*



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

end of thread, other threads:[~2020-09-23 23:05 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-21  6:46 Emacs keybindings according to file type Christopher Dimech
2020-09-21 14:16 ` Eli Zaretskii
2020-09-21 14:20   ` Christopher Dimech
2020-09-21 15:57     ` Eric S Fraga
2020-09-23  6:33   ` Christopher Dimech
2020-09-23  7:33     ` Yuri Khan
2020-09-23  7:44       ` Christopher Dimech
2020-09-23  7:52         ` Yuri Khan
2020-09-23  8:03           ` Christopher Dimech
2020-09-23  8:06           ` Marcin Borkowski
2020-09-23 23:05     ` Emanuel Berg via Users list for the GNU Emacs text editor

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.