0

For some reason, my Emacs started autocompleting code. I have noticed this in both web-mode and rjsx-mode. For example, if I type <button></ it will autocomplete it to <button></button> and move my cursor back.

I want to entirely disable this autocompletion.

I can't figure out what is causing the autocomplete. I was searching online and found references to company-mode and auto-complete-mode but neither of those seem to exist in my Emacs.

Here's my .emacs file in case it's helpful.

;; zenburn theme
(add-to-list 'custom-theme-load-path "~/.emacs.d/themes/")
(load-theme 'zenburn t)

;; nyan-mode
(add-to-list 'load-path "~/.emacs.d/vendor/nyan-mode")
(require 'nyan-mode)
(nyan-mode 1)

;; melpa
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
;; Comment/uncomment this line to enable MELPA Stable if desired.  See `package-archive-priorities`
;; and `package-pinned-packages`. Most users will not need or want to do this.
;;(add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t)
(package-initialize)
(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(inhibit-startup-screen t)
 '(package-selected-packages '(rjsx-mode web-mode slime)))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )

;; slime
(setq inferior-lisp-program "sbcl")

;; tabs/indentation
(setq-default indent-tabs-mode nil)
(setq-default tab-width 2)

(defun my-web-mode-hook ()
  "Hooks for web-mode"
  (setq web-mode-markup-indent-offset 2)
  (setq web-mode-css-indent-offset 2)
  (setq web-mode-code-indent-offset 2)
  (setq web-mode-enable-auto-pairing nil))
(add-hook 'web-mode-hook #'my-web-mode-hook)

1 Answer 1

0

Oh I think I just figured it out, it has to do with rjsx-mode.

(eval-after-load 'rjsx-mode
  '(progn
     (define-key rjsx-mode-map "<" nil)))

This disables it.

I got confused because I used M-x web-mode while I was in rjsx-mode, I guess that doesn't disable the first mode.

2
  • There will usually be many minor modes active in a buffer, but there is only ever one major mode active at any time. web-mode is certainly a major mode (I don't know anything about rjsx-mode). Calling a major mode will also cause the buffer's minor modes to be re-established (so that list may change).
    – phils
    Oct 29, 2023 at 23:20
  • FYI you can write that as (with-eval-after-load 'rjsx-mode (define-key rjsx-mode-map "<" nil)) which tends to look slightly cleaner. Note the different macro name, and no need for the quote or progn (this macro allows you to evaluate multiple forms without a progn wrapper).
    – phils
    Oct 29, 2023 at 23:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.