File tree 2 files changed +16
-11
lines changed 2 files changed +16
-11
lines changed Original file line number Diff line number Diff line change 119
119
120
120
(defun haskell-session-from-buffer ()
121
121
" Get the session based on the buffer."
122
- (when (buffer-file-name )
123
- (let ((sessions (remove-if-not (lambda (session )
124
- (haskell-is-prefix-of (file-name-directory (buffer-file-name ))
125
- (haskell-session-cabal-dir session)))
126
- haskell-sessions)))
127
- (sort sessions (lambda (a b ) (< (length (haskell-session-cabal-dir a))
128
- (length (haskell-session-cabal-dir b)))))
129
- (when (consp sessions)
130
- (car sessions)))))
122
+ (when (and (buffer-file-name )
123
+ (consp haskell-sessions))
124
+ (reduce (lambda (acc a )
125
+ (if (haskell-is-prefix-of (haskell-session-cabal-dir a)
126
+ (file-name-directory (buffer-file-name )))
127
+ (if acc
128
+ (if (and
129
+ (> (length (haskell-session-cabal-dir a))
130
+ (length (haskell-session-cabal-dir acc))))
131
+ a
132
+ acc)
133
+ a)
134
+ acc))
135
+ haskell-sessions
136
+ :initial-value nil )))
131
137
132
138
(defun haskell-session-new ()
133
139
" Make a new session."
Original file line number Diff line number Diff line change 16
16
;;;### autoload
17
17
(defun haskell-is-prefix-of (x y )
18
18
" Is x string a prefix of y string?"
19
- (string= (substring x 0 (min (length x) (length y)))
20
- (substring y 0 (min (length x) (length y)))))
19
+ (string= x (substring y 0 (min (length y) (length x)))))
21
20
22
21
(defun haskell-string ())
23
22
You can’t perform that action at this time.
0 commit comments