Skip to content

Use cl-lib instead of cl. #339

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 23, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ ELCHECKS=$(addprefix check-, $(ELFILES:.el=))

%.elc: %.el
@$(BATCH) \
--eval "(byte-compile-disable-warning 'cl-functions)" \
-f batch-byte-compile $<

.PHONY: all compile info clean check $(ELCHECKS) elpa package
Expand All @@ -63,7 +62,6 @@ $(ELCHECKS): check-%: %.el
@$(BATCH) --eval '(when (check-declare-file "$*.el") (error "check-declare failed"))'
@$(BATCH) \
--eval "(setq byte-compile-error-on-warn t)" \
--eval "(byte-compile-disable-warning 'cl-functions)" \
-f batch-byte-compile $*.el
@$(RM) $*.elc
@if [ -f "$(<:%.el=tests/%-tests.el)" ]; then \
Expand Down Expand Up @@ -121,6 +119,6 @@ $(AUTOLOADS): $(ELFILES) haskell-mode.elc
# HACK: embed version number into .elc file
haskell-mode.elc: haskell-mode.el
$(SUBST_ATAT) < haskell-mode.el > haskell-mode.tmp.el
@$(BATCH) --eval "(byte-compile-disable-warning 'cl-functions)" -f batch-byte-compile haskell-mode.tmp.el
@$(BATCH) -f batch-byte-compile haskell-mode.tmp.el
mv haskell-mode.tmp.elc haskell-mode.elc
$(RM) haskell-mode.tmp.el
40 changes: 20 additions & 20 deletions haskell-align-imports.el
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@

;;; Code:

(with-no-warnings (require 'cl))
(require 'cl-lib)

(defvar haskell-align-imports-regexp
(concat "^\\(import[ ]+\\)"
Expand Down Expand Up @@ -147,8 +147,8 @@
(when line
(let ((match
(haskell-align-imports-merge-parts
(loop for i from 1 to 8
collect (haskell-align-imports-chomp (match-string i line))))))
(cl-loop for i from 1 to 8
collect (haskell-align-imports-chomp (match-string i line))))))
(setq imports (cons (cons match (line-beginning-position))
imports)))))
(forward-line))
Expand All @@ -158,14 +158,14 @@
"Merge together parts of an import statement that shouldn't be separated."
(let ((parts (apply #'vector l))
(join (lambda (ls)
(reduce (lambda (a b)
(concat a
(if (and (> (length a) 0)
(> (length b) 0))
" "
"")
b))
ls))))
(cl-reduce (lambda (a b)
(concat a
(if (and (> (length a) 0)
(> (length b) 0))
" "
"")
b))
ls))))
(if haskell-align-imports-pad-after-name
(list (funcall join (list (aref parts 0)
(aref parts 1)
Expand Down Expand Up @@ -195,19 +195,19 @@
"Find the padding for each part of the import statements."
(if (null imports)
imports
(reduce (lambda (a b) (mapcar* #'max a b))
(mapcar (lambda (x) (mapcar #'length (car x)))
imports))))
(cl-reduce (lambda (a b) (cl-mapcar #'max a b))
(mapcar (lambda (x) (mapcar #'length (car x)))
imports))))

(defun haskell-align-imports-fill (padding line)
"Fill an import line using the padding worked out from all statements."
(mapconcat #'identity
(mapcar* (lambda (pad part)
(if (> (length part) 0)
(concat part (make-string (- pad (length part)) ? ))
(make-string pad ? )))
padding
line)
(cl-mapcar (lambda (pad part)
(if (> (length part) 0)
(concat part (make-string (- pad (length part)) ? ))
(make-string pad ? )))
padding
line)
" "))

(defun haskell-align-imports-line-match-it ()
Expand Down
18 changes: 9 additions & 9 deletions haskell-cabal.el
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
;; (fields (mapcar (lambda (sym) (substring-no-properties sym 0 -1)) syms)))
;; fields))

(with-no-warnings (require 'cl))
(require 'cl-lib)
(require 'haskell-utils)

(defconst haskell-cabal-general-fields
Expand Down Expand Up @@ -229,9 +229,9 @@ a list is returned instead of failing with a nil result."
;; http://hackage.haskell.org/packages/archive/Cabal/1.16.0.3/doc/html/Distribution-Simple-Utils.html
;; but without the exception throwing.
(let* ((cabal-files
(remove-if 'file-directory-p
(remove-if-not 'file-exists-p
(directory-files dir t ".\\.cabal\\'")))))
(cl-remove-if 'file-directory-p
(cl-remove-if-not 'file-exists-p
(directory-files dir t ".\\.cabal\\'")))))
(cond
((= (length cabal-files) 1) (car cabal-files)) ;; exactly one candidate found
(allow-multiple cabal-files) ;; pass-thru multiple candidates
Expand Down Expand Up @@ -323,12 +323,12 @@ OTHER-WINDOW use `find-file-other-window'."

(defun haskell-cabal-header-p ()
"Is the current line a section or subsection header?"
(case (haskell-cabal-classify-line)
(cl-case (haskell-cabal-classify-line)
((section-header subsection-header) t)))

(defun haskell-cabal-section-header-p ()
"Is the current line a section or subsection header?"
(case (haskell-cabal-classify-line)
(cl-case (haskell-cabal-classify-line)
((section-header) t)))


Expand Down Expand Up @@ -551,7 +551,7 @@ resultung buffer-content"

(defun haskell-cabal-listify ()
"Add commas so that buffer contains a comma-seperated list"
(case haskell-cabal-list-comma-position
(cl-case haskell-cabal-list-comma-position
('before
(goto-char (point-min))
(while (haskell-cabal-ignore-line-p) (forward-line))
Expand Down Expand Up @@ -842,7 +842,7 @@ Source names from main-is and c-sources sections are left untouched
(defun haskell-cabal-line-entry-column ()
"Column at which the line entry starts"
(save-excursion
(case (haskell-cabal-classify-line)
(cl-case (haskell-cabal-classify-line)
(section-data (beginning-of-line)
(when (looking-at "[ ]*\\(?:,[ ]*\\)?")
(goto-char (match-end 0))
Expand All @@ -860,7 +860,7 @@ Source names from main-is and c-sources sections are left untouched
(defun haskell-cabal-indent-line ()
"Indent current line according to subsection"
(interactive)
(case (haskell-cabal-classify-line)
(cl-case (haskell-cabal-classify-line)
(section-data
(save-excursion
(let ((indent (haskell-cabal-section-data-start-column
Expand Down
1 change: 0 additions & 1 deletion haskell-checkers.el
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
;;; Code:

(require 'compile)
(with-no-warnings (require 'cl))

(defgroup haskell-checkers nil
"Run HLint as inferior of Emacs, parse error messages."
Expand Down
26 changes: 13 additions & 13 deletions haskell-complete-module.el
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

;;; Code:

(require 'cl)
(require 'cl-lib)

(defcustom haskell-complete-module-preferred
'()
Expand Down Expand Up @@ -56,17 +56,17 @@
"{"
(mapconcat #'identity
(let* ((i 0))
(loop for candidate in candidates
while (<= i haskell-complete-module-max-display)
do (incf i)
collect (cond ((> i haskell-complete-module-max-display)
"...")
((= i 1)
(propertize candidate 'face 'ido-first-match-face))
(t candidate))))
(cl-loop for candidate in candidates
while (<= i haskell-complete-module-max-display)
do (cl-incf i)
collect (cond ((> i haskell-complete-module-max-display)
"...")
((= i 1)
(propertize candidate 'face 'ido-first-match-face))
(t candidate))))
" | ")
"}"))))
(case key
(cl-case key
(7 (keyboard-quit))
(backspace
(unless (null stack)
Expand All @@ -87,9 +87,9 @@
(defun haskell-complete-module (pattern candidates)
"Filter the CANDIDATES using PATTERN."
(let ((case-fold-search t))
(loop for candidate in candidates
when (haskell-complete-module-match pattern candidate)
collect candidate)))
(cl-loop for candidate in candidates
when (haskell-complete-module-match pattern candidate)
collect candidate)))

(defun haskell-complete-module-match (pattern text)
"Match PATTERN against TEXT."
Expand Down
101 changes: 50 additions & 51 deletions haskell-debug.el
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@

;;; Code:

(require 'cl)

(require 'cl-lib)
(require 'haskell-session)
(require 'haskell-process)
(require 'haskell-interactive-mode)
Expand Down Expand Up @@ -148,13 +147,13 @@
(when (y-or-n-p "Computation completed without breaking. Reload the module and retry?")
(message "Reloading and resetting breakpoints...")
(haskell-interactive-mode-reset-error (haskell-session))
(loop for break in breakpoints
do (haskell-process-file-loadish
(concat "load " (plist-get break :path))
nil
nil))
(loop for break in breakpoints
do (haskell-debug-break break))
(cl-loop for break in breakpoints
do (haskell-process-file-loadish
(concat "load " (plist-get break :path))
nil
nil))
(cl-loop for break in breakpoints
do (haskell-debug-break break))
(haskell-debug/step expr)))))))))
(haskell-debug/refresh)))

Expand Down Expand Up @@ -233,9 +232,9 @@ some old history, then display that."
(plist-get bindings :path)
(plist-get bindings :span)))
(insert "\n\n")
(loop for binding in (plist-get bindings :types)
do (insert (haskell-fontify-as-mode binding 'haskell-mode)
"\n"))))
(cl-loop for binding in (plist-get bindings :types)
do (insert (haskell-fontify-as-mode binding 'haskell-mode)
"\n"))))
(let ((history (or history
(list (haskell-debug-make-fake-history context)))))
(when history
Expand All @@ -245,20 +244,20 @@ some old history, then display that."
(defun haskell-debug-insert-history (history)
"Insert tracing HISTORY."
(let ((i (length history)))
(loop for span in history
do (let ((string (haskell-debug-get-span-string
(plist-get span :path)
(plist-get span :span)))
(index (plist-get span :index)))
(insert (propertize (format "%4d" i)
'face 'haskell-debug-trace-number-face)
" "
(haskell-debug-preview-span
(plist-get span :span)
string
t)
"\n")
(setq i (1- i))))))
(cl-loop for span in history
do (let ((string (haskell-debug-get-span-string
(plist-get span :path)
(plist-get span :span)))
(index (plist-get span :index)))
(insert (propertize (format "%4d" i)
'face 'haskell-debug-trace-number-face)
" "
(haskell-debug-preview-span
(plist-get span :span)
string
t)
"\n")
(setq i (1- i))))))

(defun haskell-debug-make-fake-history (context)
"Make a fake history item."
Expand Down Expand Up @@ -442,14 +441,14 @@ some old history, then display that."
(haskell-debug-insert-header "Modules")
(if (null modules)
(haskell-debug-insert-muted "No loaded modules.")
(progn (loop for module in modules
do (insert (propertize (plist-get module :module)
'module module
'face `((:weight bold)))
(haskell-debug-muted " - ")
(propertize (file-name-nondirectory (plist-get module :path))
'module module))
do (insert "\n")))))
(progn (cl-loop for module in modules
do (insert (propertize (plist-get module :module)
'module module
'face `((:weight bold)))
(haskell-debug-muted " - ")
(propertize (file-name-nondirectory (plist-get module :path))
'module module))
do (insert "\n")))))

(defun haskell-debug-insert-header (title)
"Insert a header title."
Expand All @@ -462,20 +461,20 @@ some old history, then display that."
(haskell-debug-insert-header "Breakpoints")
(if (null breakpoints)
(haskell-debug-insert-muted "No active breakpoints.")
(loop for break in breakpoints
do (insert (propertize (format "%d"
(plist-get break :number))
'face `((:weight bold))
'break break)
(haskell-debug-muted " - ")
(propertize (plist-get break :module)
'break break
'break break)
(haskell-debug-muted
(format " (%d:%d)"
(plist-get (plist-get break :span) :start-line)
(plist-get (plist-get break :span) :start-col)))
"\n")))
(cl-loop for break in breakpoints
do (insert (propertize (format "%d"
(plist-get break :number))
'face `((:weight bold))
'break break)
(haskell-debug-muted " - ")
(propertize (plist-get break :module)
'break break
'break break)
(haskell-debug-muted
(format " (%d:%d)"
(plist-get (plist-get break :span) :start-line)
(plist-get (plist-get break :span) :start-col)))
"\n")))
(insert "\n"))

(defun haskell-debug-insert-muted (text)
Expand Down Expand Up @@ -569,9 +568,9 @@ some old history, then display that."
(if (string= string "Empty history. Perhaps you forgot to use :trace?\n")
nil
(let ((entries (mapcar #'haskell-debug-parse-history-entry
(remove-if (lambda (line) (or (string= "<end of history>" line)
(string= "..." line)))
(haskell-debug-split-string string)))))
(cl-remove-if (lambda (line) (or (string= "<end of history>" line)
(string= "..." line)))
(haskell-debug-split-string string)))))
(set (make-local-variable 'haskell-debug-history-cache)
entries)
entries)))))
Expand Down
4 changes: 2 additions & 2 deletions haskell-decl-scan.el
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@

;;; Code:

(require 'cl-lib)
(require 'haskell-mode)
(require 'syntax)
(with-no-warnings (require 'cl))
(require 'imenu)

(defgroup haskell-decl-scan nil
Expand Down Expand Up @@ -195,7 +195,7 @@ current line that starts with REGEXP and is not in `font-lock-comment-face'."
"Like haskell-ds-move-to-start-regexp, but uses syntax-ppss to
skip comments"
(let (p)
(loop
(cl-loop
do (setq p (point))
(haskell-ds-move-to-start-regexp inc regexp)
while (and (nth 4 (syntax-ppss))
Expand Down
1 change: 0 additions & 1 deletion haskell-doc.el
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,6 @@
(require 'haskell-mode)
(require 'inf-haskell)
(require 'imenu)
(with-no-warnings (require 'cl))

(defgroup haskell-doc nil
"Show Haskell function types in echo area."
Expand Down
Loading