From 53577db05b027787b190bd1934ec72ae045b7df1 Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 6 Mar 2008 02:14:17 +0000 Subject: * misc/ruby-mode.el (ruby-add-log-current-method): use ruby style method name format. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15704 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ misc/ruby-mode.el | 41 +++++++++++++++++++++++++++++++++-------- 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 11fc68e67b..ee55ff3308 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Mar 6 11:14:14 2008 Nobuyoshi Nakada + + * misc/ruby-mode.el (ruby-add-log-current-method): use ruby style + method name format. + Thu Mar 6 11:12:29 2008 Nobuyoshi Nakada * sprintf.c (rb_str_format): no need of loop. diff --git a/misc/ruby-mode.el b/misc/ruby-mode.el index 49a43ae17d..da2cd16aa2 100644 --- a/misc/ruby-mode.el +++ b/misc/ruby-mode.el @@ -1001,17 +1001,19 @@ balanced expression is found." "Return current method string." (condition-case nil (save-excursion - (let ((mlist nil) (indent 0)) + (let (mname mlist (indent 0)) ;; get current method (or class/module) (if (re-search-backward (concat "^[ \t]*\\(def\\|class\\|module\\)[ \t]+" - "\\(" - ;; \\. for class method - "\\(" ruby-symbol-re "\\|\\." "\\)" + "\\(" + ;; \\. and :: for class method + "\\([A-Za-z_]" ruby-symbol-re "*\\|\\.\\|::" "\\)" "+\\)") nil t) (progn - (setq mlist (list (match-string 2))) + (setq mname (match-string 2)) + (unless (string-equal "def" (match-string 1)) + (setq mlist (list mname) mname nil)) (goto-char (match-beginning 1)) (setq indent (current-column)) (beginning-of-line))) @@ -1020,7 +1022,7 @@ balanced expression is found." (re-search-backward (concat "^[ \t]*\\(class\\|module\\)[ \t]+" - "\\([A-Z]" ruby-symbol-re "+\\)") + "\\([A-Z]" ruby-symbol-re "*\\)") nil t)) (goto-char (match-beginning 1)) (if (< (current-column) indent) @@ -1028,10 +1030,33 @@ balanced expression is found." (setq mlist (cons (match-string 2) mlist)) (setq indent (current-column)) (beginning-of-line)))) + (when mname + (let ((mn (split-string mname "\\.\\|::"))) + (if (cdr mn) + (progn + (cond + ((string-equal "" (car mn)) + (setq mn (cdr mn) mlist nil)) + ((string-equal "self" (car mn)) + (setq mn (cdr mn))) + ((let ((ml (nreverse mlist))) + (while ml + (if (string-equal (car ml) (car mn)) + (setq mlist (nreverse (cdr ml)) ml nil)) + (or (setq ml (cdr ml)) (nreverse mlist)))))) + (if mlist + (setcdr (last mlist) mn) + (setq mlist mn)) + (setq mn (last mn 2)) + (setq mname (concat "." (cadr mn))) + (setcdr mn nil)) + (setq mname (concat "#" mname))))) ;; generate string (if (consp mlist) - (mapconcat (function identity) mlist "::") - nil))))) + (setq mlist (mapconcat (function identity) mlist "::"))) + (if mname + (if mlist (concat mlist mname) mname) + mlist))))) (cond ((featurep 'font-lock) -- cgit v1.2.3