(To add your own modes, check the value of the major-mode variable ( C-h v or M-x describe-variable) and add it to the list.)Īlternatively, you may define a separate yank-and-indent command as such: ( defun yank-and-indent () emacs file and enjoy automatic indentation of yanked text in the listed programming modes.įall back to default, non-indented yanking by preceding the yanking commands with C-u. (indent-region (region-beginning) (region-end) nil)))))) ( let ((mark-even-if-inactive transient-mark-mode)) (member major-mode '(emacs-lisp-mode lisp-mode (eval `( defadvice ,command (after indent-region activate) The following code (inspired by this post) accomplishes this beautifully: ( dolist (command '(yank yank-pop)) This should be fairly straightforward to implement in Emacs, but how?” “In TextMate, pasted lines are automatically indented, which is extremely time-saving. Targzeta Auto-indent yanked (pasted) code (add-hook 'python-mode-hook 'set-newline-and-indent) "Map the return key with ` newline-and-indent'" (add-hook 'electric-indent-functions 'electric-indent-ignore-python) "Ignore electric indentation for python-mode" ( defun electric-indent-ignore-python (char) You can use this snippet: Indentation for python Ignoring electric indentation Seem that electric-indent-mode doesn’t work properly with python-mode. ( lambda () (local-set-key (kbd "RET") 'reindent-then-newline-and-indent))) One must write something like: (add-hook 'f90-mode-hook Incidentally, f90-mode (for Fortran 90, Fortran 95, etc.) is one in which redefining the key in the global-map does not work. On the other hand, this thing is a little bit cleaner and works with most modes: (define-key global-map (kbd "RET") 'newline-and-indent)įor some programming languages, e.g., Fortran, using reindent-then-newline-and-indent instead of newline-and-indent may be clearer. (add-hook 'lisp-mode-hook 'set-newline-and-indent) (local-set-key (kbd "RET") 'newline-and-indent)) If you feel squeamish about using anonymous functions in your hooks, the following will work just as well: ( defun set-newline-and-indent () ![]() Note that for any mode derived from c-mode, the hook c-mode-common-hook will do the trick. Replace lisp-mode-hook with the appropriate hook. (local-set-key (kbd "RET") 'newline-and-indent))) ![]() emacs: (add-hook 'lisp-mode-hook '( lambda () Add something along the following lines to your. If you really like it, you might want to bind it to RET. If you want automatic indentation, try to use C-j instead of RET for a while. NOTE: Recent changes, I think during Emacs 24.3, have swapped effects of RET and C-j, so RET typically does newline-and-indent. + the theme tango-dark (not too long from zenbrun). Use M-x load-theme instead, suggestedly with (setq-default buffer-file-coding-system 'dos) + '(font-lock-preprocessor-face ((t (:inherit font-lock-builtin-face :foreground "orange" :weight bold))))) + '(font-lock-comment-face ((t (:foreground "limegreen" :slant oblique)))) '(font-lock-preprocessor-face ((t (:inherit font-lock-builtin-face :foreground "orange" :weight bold))))) '(font-lock-comment-face ((t (:foreground "limegreen" :slant oblique)))) ![]() If there is more than one, they won't work right. Your init file should contain only one such instance. If you edit it by hand, you could mess it up, so be careful. (set-face-attribute 'default nil :height -83,13 +83,13 t) (set-face-attribute 'default nil :height 90) The commit introducing the issue does not seem like touching anything related, though: Commented out offending lines in init.el. Luckily I version control my init files, and I could find when this behavior started to happen. Starting emacs with no init file, it works fine. How can I make auto-fill-mode skip the "new line is indented" part? This is an explanation of the reason for a change I made, for exampleĪ bug fix or a new feature which will save the world from all evil They tend to look like this: Make the world a better place This is not practical for me, for example when I write commit messages. Otherwise the new line is indented, as though you had typed on This is to be expected, since the doc says: ![]() When writing text (Fundamental) in auto-fill-mode, the second line after an automatic line break is indented.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |