File tree Expand file tree Collapse file tree 4 files changed +42
-6
lines changed Expand file tree Collapse file tree 4 files changed +42
-6
lines changed Original file line number Diff line number Diff line change 2
2
3
3
All notable changes of the PHP Mode 1.19.1 release series are documented in this file using the [ Keep a CHANGELOG] ( http://keepachangelog.com/ ) principles.
4
4
5
+ ## [ 1.21.2]
6
+
7
+ ### Fixed
8
+
9
+ * Function ` php-beginning-of-defun ` should return non-nil on success
10
+ ([ #503 ] ( https://github.com/emacs-php/php-mode/issues/503 ) )
11
+
5
12
## [ 1.21.1] - 2019-04-01
6
13
7
14
### Changed
Original file line number Diff line number Diff line change @@ -949,4 +949,28 @@ as a keyword."
949
949
(should (string= (abbreviate-file-name default-directory)
950
950
(php-project-get-root-dir))))
951
951
952
+ (defun php-mode-test-in-function-p (&optional pos )
953
+ " Determine whether POS is inside a function.
954
+ Meant for `php-mode-test-issue-503' ."
955
+ (let (bof (pos (or pos (point ))))
956
+ (save-excursion
957
+ (when (beginning-of-defun )
958
+ (setq bof (point ))
959
+ (end-of-defun )
960
+ (and (> pos bof)
961
+ (< pos (point )))))))
962
+
963
+ (ert-deftest php-mode-test-issue-503 ()
964
+ " Function `php-beginning-of-defun' should return non-nil on success."
965
+ (with-php-mode-test
966
+ (" issue-503.php" )
967
+ (php-mode)
968
+ (goto-char (point-max ))
969
+ (should (eq (php-mode-test-in-function-p) nil ))
970
+ (should (eq (php-mode-test-in-function-p (1- (point ))) t ))
971
+ (should (eq (php-mode-test-in-function-p 1 ) nil ))
972
+ (should (eq (php-mode-test-in-function-p 24 ) t ))
973
+ (goto-char (point-min ))
974
+ (should (eq (php-mode-test-in-function-p nil ) nil ))))
975
+
952
976
; ;; php-mode-test.el ends here
Original file line number Diff line number Diff line change @@ -786,10 +786,10 @@ but only if the setting is enabled"
786
786
" Move to the beginning of the ARGth PHP function from point.
787
787
Implements PHP version of `beginning-of-defun-function' ."
788
788
(interactive " p" )
789
- (let ((arg (or arg 1 )))
789
+ (let (found-p (arg (or arg 1 )))
790
790
(while (> arg 0 )
791
- (re-search-backward php-beginning-of-defun-regexp
792
- nil 'noerror )
791
+ (setq found-p ( re-search-backward php-beginning-of-defun-regexp
792
+ nil 'noerror ) )
793
793
(setq arg (1- arg)))
794
794
(while (< arg 0 )
795
795
(end-of-line 1 )
@@ -798,9 +798,10 @@ Implements PHP version of `beginning-of-defun-function'."
798
798
(forward-list 2 )
799
799
(forward-line 1 )
800
800
(if (eq opoint (point ))
801
- (re-search-forward php-beginning-of-defun-regexp
802
- nil 'noerror ))
803
- (setq arg (1+ arg))))))
801
+ (setq found-p (re-search-forward php-beginning-of-defun-regexp
802
+ nil 'noerror )))
803
+ (setq arg (1+ arg))))
804
+ (not (null found-p))))
804
805
805
806
(defun php-end-of-defun (&optional arg )
806
807
" Move the end of the ARGth PHP function from point.
Original file line number Diff line number Diff line change
1
+ <?php
2
+ function foo () {
3
+
4
+ }
You can’t perform that action at this time.
0 commit comments