diff options
| author | Damien Cassou | 2017-04-12 07:35:56 +0200 |
|---|---|---|
| committer | Nicolas Petton | 2017-04-13 11:44:17 +0200 |
| commit | 4e77ff0d45b88cade7836c01344cd8d892adfde8 (patch) | |
| tree | 52537b9cc31b0bde9384aeec939fb24b546790e8 /lisp | |
| parent | 88e012511ac6bfd7eb31b14d792ab0005e3693a8 (diff) | |
| download | emacs-4e77ff0d45b88cade7836c01344cd8d892adfde8.tar.gz emacs-4e77ff0d45b88cade7836c01344cd8d892adfde8.zip | |
Fix imenu--sort-by-position for non-pairs parameters (bug#26457)
* lisp/imenu.el (imenu--sort-by-position): Fix to accept lists beyond
pairs.
* test/lisp/imenu-tests.el: Add 2 tests for `imenu--sort-by-position`.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/imenu.el | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lisp/imenu.el b/lisp/imenu.el index 0f47a92734e..c1fd4005ab6 100644 --- a/lisp/imenu.el +++ b/lisp/imenu.el | |||
| @@ -499,7 +499,12 @@ An item looks like (NAME . POSITION)." | |||
| 499 | (string-lessp (car item1) (car item2))) | 499 | (string-lessp (car item1) (car item2))) |
| 500 | 500 | ||
| 501 | (defun imenu--sort-by-position (item1 item2) | 501 | (defun imenu--sort-by-position (item1 item2) |
| 502 | (< (cdr item1) (cdr item2))) | 502 | "Comparison function to sort items depending on their position. |
| 503 | Return non-nil if and only if ITEM1's position is lower than ITEM2's | ||
| 504 | position." | ||
| 505 | (if (listp (cdr item1)) | ||
| 506 | (< (cadr item1) (cadr item2)) | ||
| 507 | (< (cdr item1) (cdr item2)))) | ||
| 503 | 508 | ||
| 504 | (defun imenu--relative-position (&optional reverse) | 509 | (defun imenu--relative-position (&optional reverse) |
| 505 | "Support function to calculate relative position in buffer. | 510 | "Support function to calculate relative position in buffer. |