Skip to content

Commit b7e3687

Browse files
committed
Rewrite flet-usage in terms of funcall
Alas, `flet` becomes officially obsolete starting with Emacs 24.3; Otoh, `cl-flet` is not available in the backported `cl-lib-0.3` (due to subtle differences between `flet` and `cl-flet`). Thus, to avoid annoying compile warnings, the easiest course of action is to not use `flet` altogether.
1 parent fa5672f commit b7e3687

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

haskell-mode.el

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -775,18 +775,14 @@ This function will be called with no arguments.")
775775
replace the whole buffer with the output. If CMD fails the
776776
buffer remains unchanged."
777777
(set-buffer-modified-p t)
778-
(flet
779-
((chomp (str)
780-
(while (string-match "\\`\n+\\|^\\s-+\\|\\s-+$\\|\n+\\'"
781-
str)
782-
(setq str (replace-match "" t t str)))
783-
str)
784-
(errout
785-
(fmt &rest args)
786-
(let* ((warning-fill-prefix " "))
787-
(display-warning cmd (apply 'format fmt args) :warning))))
788-
(let*
789-
((filename (buffer-file-name (current-buffer)))
778+
(let* ((chomp (lambda (str)
779+
(while (string-match "\\`\n+\\|^\\s-+\\|\\s-+$\\|\n+\\'" str)
780+
(setq str (replace-match "" t t str)))
781+
str))
782+
(errout (lambda (fmt &rest args)
783+
(let* ((warning-fill-prefix " "))
784+
(display-warning cmd (apply 'format fmt args) :warning))))
785+
(filename (buffer-file-name (current-buffer)))
790786
(cmd-prefix (replace-regexp-in-string " .*" "" cmd))
791787
(tmp-file (make-temp-file cmd-prefix))
792788
(err-file (make-temp-file cmd-prefix))
@@ -800,26 +796,26 @@ This function will be called with no arguments.")
800796
(stderr-output
801797
(with-temp-buffer
802798
(insert-file-contents err-file)
803-
(chomp (buffer-substring-no-properties (point-min) (point-max)))))
799+
(funcall chomp (buffer-substring-no-properties (point-min) (point-max)))))
804800
(stdout-output
805801
(with-temp-buffer
806802
(insert-file-contents tmp-file)
807803
(buffer-substring-no-properties (point-min) (point-max)))))
808804
(if (string= "" stderr-output)
809805
(if (string= "" stdout-output)
810-
(errout
806+
(funcall errout
811807
"Error: %s produced no output, leaving buffer alone" cmd)
812808
(save-restriction
813809
(widen)
814810
;; command successful, insert file with replacement to preserve
815811
;; markers.
816812
(insert-file-contents tmp-file nil nil nil t)))
817813
;; non-null stderr, command must have failed
818-
(errout "%s failed: %s" cmd stderr-output)
814+
(funcall errout "%s failed: %s" cmd stderr-output)
819815
)
820816
(delete-file tmp-file)
821817
(delete-file err-file)
822-
)))
818+
))
823819

824820
(defun haskell-mode-stylish-buffer ()
825821
"Apply stylish-haskell to the current buffer."

0 commit comments

Comments
 (0)