Tab Indentation instead of Spaces in Emacs Ruby Mode

I am trying to configure Emacs to insert a “tab” instead of a series of “spaces” as the Ruby code retreats.

So far, I have been trying to set the var parameter ruby-indent-tabs-modeto tso that, according to the documentation, it "inserts tabs into ruby ​​mode if it's not zero." But still no dice.

I also tried setting it up with the help Easy customisationthat inserted the following into mine init.el:

(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.
 '(ruby-indent-tabs-mode t))
(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.
 )

And after checking the variable through C-h v, it reports that the variable is set to t, but pressing TABcontinues to insert spaces.

I even tried to edit the file .elfor ruby ​​mode and did not recompile it.

.

----- EDIT -----

, C-h m:

: Auto-Complete Auto-Composition
-Shadow Font-Lock
Global-Auto-Complete Global-Font-Lock Inf-Ruby Line-Number Menu-Bar


Show-Smartparens Show-Smartparens-Global Smartparens
Smartparens-Global Transient-Mark

init.el :

(require 'cask "/Users/snowingheart/.cask/cask.el")
(cask-initialize)
(require 'pallet)

(add-to-list 'load-path "~/elisp")
(load "php-mode")
(add-to-list 'auto-mode-alist
             '("\\.php[34]?\\'\\|\\.phtml\\'" . php-mode))

(global-set-key (kbd "C-x <up>") 'windmove-up)
(global-set-key (kbd "C-x <down>") 'windmove-down)
(global-set-key (kbd "C-x <right>") 'windmove-right)
(global-set-key (kbd "C-x <left>") 'windmove-left)

(require 'package)
(add-to-list 'package-archives
    '("marmalade" .
      "http://marmalade-repo.org/packages/"))
(package-initialize)

(global-set-key (kbd "C-x >") 'mc/mark-next-like-this)
(global-set-key (kbd "C-x <") 'mc/mark-previous-like-this)
(global-set-key (kbd "C-c C-<") 'mc/mark-all-like-this)
(global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines)

(require 'smartparens-config)
(require 'smartparens-ruby)
(require 'smartparens-erb)
(smartparens-global-mode)
(show-smartparens-global-mode t)

(sp-with-modes '(rhtml-mode)
               (sp-local-pair "<%=" "%>")
               (sp-local-pair "<%-" "%>"))
(require 'auto-complete-config)
(add-to-list 'ac-dictionary-directories
             "~/.emacs.d/.cask/24.3.50.1/elpa/auto-complete-20130724.1750/dict")
(ac-config-default)
(setq ac-ignore-case nil)
(add-to-list 'ac-modes 'enh-ruby-mode)
(add-to-list 'ac-modes 'web-mode)

(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.
 '(indent-tabs-mode t)
 '(ruby-indent-tabs-mode t))
(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.
 )

(setq-default indent-tabs-mode t)
(setq enh-ruby-indent-tabs-mode t)

(smart-tabs-insinuate 'ruby)
(smart-tabs-advice ruby-indent-line ruby-indent-level)
(setq ruby-indent-tabs-mode t)
+4
1

init.el ( , ):

(setq-default indent-tabs-mode t)

indent-tabs-mode:

, .

ruby-mode, indent-tabs-mode ruby-indent-tabs-mode. indent-tabs-mode t ( , ruby-indent-tabs-mode). , Emacs .


, enh-ruby-mode enh-ruby-indent-tabs-mode nil. indent-tabs-mode, indent-tabs-mode to t enh-ruby-mode.

, ruby-mode enh-ruby-mode, indent-tabs-mode,

(setq enh-ruby-indent-tabs-mode t)

init.el .


EDIT ( )

(: .)

  • Emacs 24.3.1

  • ruby-mode 1.2 ()

  • enh-ruby-mode 20140406.252 ( ​​ M-x package-install...)

, init.el:

(package-initialize)

(setq-default tab-width 2)
(setq enh-ruby-indent-tabs-mode t)
(defvaralias 'enh-ruby-indent-level 'tab-width)
(defvaralias 'enh-ruby-hanging-indent-level 'tab-width)

, Emacs. , , custom-set-variables , , init.el, .

, , Emacs , C-q TAB.


, enh-ruby-mode, - , , enh-ruby-indent-tabs-mode t. / enh-ruby-mode , , .

+2

Source: https://habr.com/ru/post/1535450/


All Articles