branch: elpa/haskell-mode
commit 7f452cc9e6c3316b5a4a2b790d3a396f271609d9
Merge: 80054782bf d7b05e4b04
Author: Steve Purcell <[email protected]>
Commit: GitHub <[email protected]>
Merge pull request #1864 from pacastega/imenu-preserve-order
Add user option to preserve the order of imenu candidates
---
haskell-decl-scan.el | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/haskell-decl-scan.el b/haskell-decl-scan.el
index f32515ac6f..8299f34e61 100644
--- a/haskell-decl-scan.el
+++ b/haskell-decl-scan.el
@@ -124,6 +124,11 @@
:group 'haskell-decl-scan
:type 'boolean)
+(defcustom haskell-decl-scan-sort-imenu t
+ "Whether to sort the candidates in imenu."
+ :group 'haskell-decl-scan
+ :type 'boolean)
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; General declaration scanning functions.
@@ -562,15 +567,21 @@ datatypes) in a Haskell file for the `imenu' package."
(import . "Imports") (class . "Classes")))
(when-let ((curr-alist (gethash (car type) imenu)))
(push (cons (cdr type)
- (sort curr-alist 'haskell-ds-imenu-label-cmp))
+ (if haskell-decl-scan-sort-imenu
+ (sort curr-alist 'haskell-ds-imenu-label-cmp)
+ (reverse curr-alist)))
index-alist)))
(when-let ((var-alist (gethash 'variable imenu)))
(if haskell-decl-scan-bindings-as-variables
(push (cons "Variables"
- (sort var-alist 'haskell-ds-imenu-label-cmp))
+ (if haskell-decl-scan-sort-imenu
+ (sort var-alist 'haskell-ds-imenu-label-cmp)
+ (reverse var-alist)))
index-alist)
(setq index-alist (append index-alist
- (sort var-alist
'haskell-ds-imenu-label-cmp)))))
+ (if haskell-decl-scan-sort-imenu
+ (sort var-alist
'haskell-ds-imenu-label-cmp)
+ (reverse var-alist))))))
;; Return the alist.
index-alist))