开发工具 emacs ruby-mode 缩进不了

dbian · 2012年10月31日 · 最后由 xuefuqiao 回复于 2013年07月22日 · 5468 次阅读

按 tab 说

ruby-indent-line: Wrong type argument: number-or-marker-p, nil

现在只能输入 4 个空格来代替了,我对 lisp 是只有能看懂的水平。。望大侠求救

don't 沉了。。

匿名 #2 2012年10月31日

#1 楼 @dbian ruby-indent-line is a function

我按了 C-h k TAB,下面是触发的函数 ruby-indent-line is an interactive compiled Lisp function in `ruby-mode.el'.

(ruby-indent-line &optional FLAG)

Correct the indentation of the current ruby line.

[back] 打开了 ruby-mode.el,找到了这个函数

(defun ruby-indent-line (&optional flag) "Correct the indentation of the current ruby line." (interactive) (ruby-indent-to (ruby-calculate-indent)))

不知道怎么解决,寝室里的电脑也是这样,ruby-mode 的 TAB 一样用不了,你们的可以用吗

#2 楼 @DoIT 它确实是一个 function,然后呢?

匿名 #4 2012年10月31日

#1 楼 @dbian show me your .emacs file and your emacs version number

---------来了,emacs 版本是 24.2 ------------

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

;;this can auto install missing plugins (when (not package-archive-contents) (package-refresh-contents))

;; Add in your own as you wish: (defvar my-packages '(starter-kit starter-kit-lisp starter-kit-bindings auto-complete markdown-mode python-mode bm coffee-mode sass-mode scss-mode tabbar tabbar-ruler yasnippet smex color-theme color-theme-monokai magit ) "A list of packages to ensure are installed at launch.")

(dolist (p my-packages) (when (not (package-installed-p p)) (package-install p)))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;begin basic settings (global-linum-mode t) (setq-default make-backup-files nil) (auto-image-file-mode t) (show-paren-mode t) ;;begin ido (ido-mode t) ;;滚轮加 ctrl 可以快速切换 buffer (global-set-key (kbd "") 'switch-to-prev-buffer) (global-set-key (kbd "") 'switch-to-next-buffer) ;;quick kill buffer with F5 (global-set-key [f5] 'kill-this-buffer) (global-set-key [C-f6] 'magit-status) (global-set-key [C-f5] 'shell) (global-set-key [C-f4] 'revert-buffer) (global-set-key [C-f1] 'package-list-packages)

;;ispell set to english ;;(setq ispell-dictionary "english") (add-to-list 'load-path "~/emacs_plugins") (add-to-list 'load-path "~/.emacs.d/elpa/color-theme-6.5.5/") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;(add-to-list 'load-path "/home/alex/.emacs.d/elpa/yasnippet-0.8.0") ;;begin yasnippet (require 'yasnippet) ;;(require yasnippet-bundle) (yas-global-mode 1) ;;begin scss/sass (setq scss-compile-at-save nil) ;;begin magit (require 'magit) ;;begin line cut&copy (defadvice kill-ring-save (before slickcopy activate compile) "When called interactively with no active region, copy a single line instead." (interactive (if mark-active (list (region-beginning) (region-end)) (list (line-beginning-position) (line-beginning-position 2)))))

(defadvice kill-region (before slickcut activate compile) "When called interactively with no active region, kill a single line instead." (interactive (if mark-active (list (region-beginning) (region-end)) (list (line-beginning-position) (line-beginning-position 2))))) ;;begin tabbar (require 'tabbar) (require 'ide-skel) ;; optional, but useful - see Emacs Manual (partial-completion-mode) (icomplete-mode) ;; for convenience ;;(global-set-key [C-f4] 'ide-skel-proj-find-files-by-regexp) ;;(global-set-key [C-f5] 'ide-skel-proj-grep-files-by-regexp) (global-set-key [C-f10] 'ide-skel-toggle-left-view-window) (global-set-key [C-f11] 'ide-skel-toggle-bottom-view-window) (global-set-key [C-f12] 'ide-skel-toggle-right-view-window) (global-set-key [C-next] 'tabbar-backward) (global-set-key [C-prior] 'tabbar-forward)

;;viper-mode ;;(setq viper-mode t) ;;(require 'viper)

;;begin tail (require 'highlight-tail) (highlight-tail-mode t) (setq highlight-tail-colors '(("black" . 0) ("#bc2525" . 25) ("black" . 66))) (highlight-tail-mode nil) (highlight-tail-mode t) ;;markdown mode (autoload 'markdown-mode "markdown-mode.el" "Major mode for editing Markdown files" t) (setq auto-mode-alist (cons '("\.text" . markdown-mode) auto-mode-alist)) (setq auto-mode-alist (cons '("\.md" . markdown-mode) auto-mode-alist)) (setq auto-mode-alist (cons '("\.markdown" . markdown-mode) auto-mode-alist))

;;newsticker (autoload 'w3m-region "w3m" nil t) (setq newsticker-html-renderer 'w3m-region)

;;tab show ;;(require 'ctab) ;;(ctab-mode t)

;;python-mode.el 配置 ;;文件关联,自动将 py 后缀的文件和 pyhton-mod 关联 (load "python-mode.el") (setq auto-mode-alist (cons '("\.py$" . python-mode) auto-mode-alist)) (setq interpreter-mode-alist (cons '("python" . python-mode) interpreter-mode-alist)) ;;自动加载,将 python-mode 和文件 python-mode.elc 关联 (autoload 'python-mode "python-mode" "Python editing mode." t) (global-font-lock-mode t) ;语法加亮 (setq font-lock-maximum-decoration t)

;;M-; ;;smart quote ;;(require 'smartq)

;;a-c (require 'auto-complete-config) (global-auto-complete-mode t) (setq-default ac-sources '(ac-source-words-in-same-mode-buffers)) (add-hook 'emacs-lisp-mode-hook (lambda () (add-to-list 'ac-sources 'ac-source-symbols))) (add-hook 'auto-complete-mode-hook (lambda () (add-to-list 'ac-sources 'ac-source-filename))) (set-face-background 'ac-candidate-face "lightgray") (set-face-underline 'ac-candidate-face "darkgray") (set-face-background 'ac-selection-face "steelblue") (define-key ac-completing-map "\M-n" 'ac-next) ;;; 列表中通过按 M-n 来向下移动 (define-key ac-completing-map "\M-p" 'ac-previous) (setq ac-auto-start t) (setq ac-dwim t)

;;image (auto-image-file-mode t)

;;(smart-tab-mode t ) ;;(smart-tabs-advice ruby-indent-line ruby-indent-level) (setq ruby-indent-tabs-mode nil) ;;begin color-theme (require 'color-theme) (color-theme-monokai) ;;end ;;system settings ;;

(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. '(ansi-color-names-vector ["#242424" "#e5786d" "#95e454" "#cae682" "#8ac6f2" "#333366" "#ccaa8f" "#f6f3e8"]) '(blink-cursor-mode nil) '(display-time-mode t) '(inhibit-startup-screen t) '(ispell-local-dictionary "english") '(show-paren-mode t) '(text-mode-hook (quote (text-mode-hook-identify))) '(tool-bar-mode nil)) (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. '(tabbar-button-highlight ((t (:inherit tabbar-button)))) '(tabbar-default ((t (:inherit variable-pitch :background "gray82" :foreground "gray50" :height 0.8)))) '(tabbar-highlight ((t nil))) '(tabbar-selected ((t (:inherit tabbar-default :background "white" :foreground "blue" :box (:line-width 1 :color "black"))))) '(tabbar-separator ((t (:inherit tabbar-default :height 0.2)))) '(tabbar-unselected ((t (:inherit tabbar-default :background "gray72" :foreground "black" :box (:line-width 1 :color "black")))))) (put 'dired-find-alternate-file 'disabled nil)

#4 楼 晕,缩进了也没语法高亮啊

匿名 #7 2012年10月31日

#6 楼 @dbian

(autoload 'smart-tabs-mode "smart-tabs-mode"
    "Intelligently indent with tabs, align with spaces!")
(autoload 'smart-tabs-mode-enable "smart-tabs-mode")
(autoload 'smart-tabs-advice "smart-tabs-mode")

(smart-tabs-advice ruby-indent-line ruby-indent-level)
(setq ruby-indent-tabs-mode t)
匿名 #8 2012年10月31日

#6 楼 @dbian read the fucking installation guide

#8 楼 @DoIT 可以了,总算勉强能用了,谢谢你。不过好像必须要装 smart-tab(我之前以为是他在搞鬼,所以就把它卸了,我的代码里也注释掉了)。 而且它的 wiki 里写的很误导人,必须要加入一段 C-like languages 里面的代码才能用,传送门,http://www.emacswiki.org/SmartTabs#toc6

再次感谢@DoIT 的路见不平拔刀相助!!

#5 楼 @dbian Emacs24+ 的话,我感觉还是deftheme方便,为什么要用 color-theme?

需要 登录 后方可回复, 如果你还没有账号请 注册新账号