branch: externals/phps-mode commit 67b8701c537252047f942a6de5644f4bc9a4e7b8 Author: Christian Johansson <christ...@cvj.se> Commit: Christian Johansson <christ...@cvj.se>
Decreased length of imenu items to prevent truncation --- phps-mode-functions.el | 13 ++++++------- phps-mode-test-functions.el | 8 ++++---- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/phps-mode-functions.el b/phps-mode-functions.el index e7b54fd..9e405a1 100644 --- a/phps-mode-functions.el +++ b/phps-mode-functions.el @@ -618,7 +618,6 @@ ;; (message "phps-mode-functions-after-change %s %s %s" start stop length) )) -;; TODO Implement this (defun phps-mode-functions-imenu-create-index-function () "Create index for imenu." (let ((index '())) @@ -669,7 +668,7 @@ (setq in-namespace-declaration nil)) ((equal token-symbol 'T_STRING) - (let ((index-name (format "namespace %s" (buffer-substring-no-properties token-start token-end))) + (let ((index-name (format "\\%s" (buffer-substring-no-properties token-start token-end))) (index-pos token-start)) (setq in-namespace-name index-name) (push `(,index-name . ,index-pos) index))))) @@ -682,11 +681,11 @@ (setq in-class-declaration nil)) ((equal token-symbol 'T_STRING) - (let ((index-name (format "class %s" (buffer-substring-no-properties token-start token-end))) + (let ((index-name (format "%s" (buffer-substring-no-properties token-start token-end))) (index-pos token-start)) (setq in-class-name index-name) (when in-namespace-name - (setq index-name (concat in-namespace-name " \\ " index-name))) + (setq index-name (concat in-namespace-name "\\" index-name))) (push `(,index-name . ,index-pos) index))))) (in-function-declaration @@ -700,12 +699,12 @@ (setq in-function-declaration nil)) ((equal token-symbol 'T_STRING) - (let ((index-name (format "function %s" (buffer-substring-no-properties token-start token-end))) + (let ((index-name (format "%s()" (buffer-substring-no-properties token-start token-end))) (index-pos token-start)) (when in-class-name - (setq index-name (concat in-class-name " -> " index-name))) + (setq index-name (concat in-class-name "->" index-name))) (when in-namespace-name - (setq index-name (concat in-namespace-name " \\ " index-name))) + (setq index-name (concat in-namespace-name "\\" index-name))) (push `(,index-name . ,index-pos) index))))) (t diff --git a/phps-mode-test-functions.el b/phps-mode-test-functions.el index a9550e9..3b7e320 100644 --- a/phps-mode-test-functions.el +++ b/phps-mode-test-functions.el @@ -589,22 +589,22 @@ (phps-mode-test-with-buffer "<?php\nfunction myFunctionA() {}\nfunction myFunctionB() {}\n" "Imenu function-oriented file" - (should (equal (phps-mode-functions-imenu-create-index-function) '(("function myFunctionA" . 16) ("function myFunctionB" . 42))))) + (should (equal (phps-mode-functions-imenu-create-index-function) '(("myFunctionA()" . 16) ("myFunctionB()" . 42))))) (phps-mode-test-with-buffer "<?php\nclass myClass {\n public function myFunctionA() {}\n protected function myFunctionB() {}\n}\n" "Imenu object-oriented file" - (should (equal (phps-mode-functions-imenu-create-index-function) '(("class myClass" . 13) ("class myClass -> function myFunctionA" . 43) ("class myClass -> function myFunctionB" . 83))))) + (should (equal (phps-mode-functions-imenu-create-index-function) '(("myClass" . 13) ("myClass->myFunctionA()" . 43) ("myClass->myFunctionB()" . 83))))) (phps-mode-test-with-buffer "<?php\nnamespace myNamespace {\n class myClass {\n public function myFunctionA() {}\n protected function myFunctionB() {}\n }\n}\n" "Imenu object-oriented file with namespace, class and function" - (should (equal (phps-mode-functions-imenu-create-index-function) '(("namespace myNamespace" . 17) ("namespace myNamespace \\ class myClass" . 41) ("namespace myNamespace \\ class myClass -> function myFunctionA" . 75) ("namespace myNamespace \\ class myClass -> function myFunctionB" . 119))))) + (should (equal (phps-mode-functions-imenu-create-index-function) '(("\\myNamespace" . 17) ("\\myNamespace\\myClass" . 41) ("\\myNamespace\\myClass->myFunctionA()" . 75) ("\\myNamespace\\myClass->myFunctionB()" . 119))))) (phps-mode-test-with-buffer "<?php\nnamespace myNamespace;\nclass myClass {\n public function myFunctionA() {}\n protected function myFunctionB() {}\n}\n" "Imenu object-oriented file with bracket-less namespace, class and function" - (should (equal (phps-mode-functions-imenu-create-index-function) '(("namespace myNamespace" . 17) ("namespace myNamespace \\ class myClass" . 36) ("namespace myNamespace \\ class myClass -> function myFunctionA" . 66) ("namespace myNamespace \\ class myClass -> function myFunctionB" . 106))))) + (should (equal (phps-mode-functions-imenu-create-index-function) '(("\\myNamespace" . 17) ("\\myNamespace\\myClass" . 36) ("\\myNamespace\\myClass->myFunctionA()" . 66) ("\\myNamespace\\myClass->myFunctionB()" . 106))))) )