syl20bnr / spacemacs

A community-driven Emacs distribution - The best editor is neither Emacs nor Vim, it's Emacs *and* Vim!
http://spacemacs.org
GNU General Public License v3.0
23.7k stars 4.9k forks source link

`cl` Package Deprecated #12989

Closed equwal closed 4 years ago

equwal commented 4 years ago

The cl package is deprecated (use cl-lib); this results in a message warning on startup. Here are all the core files which (require 'cl) on the current (2019-11-24) dev branch:

core/core-configuration-layer.el
core/libs/ht.el
core/libs/mocker.el
core/tools/spacefmt/spacefmt.el
layers/+chat/erc/local/erc-sasl/erc-sasl.el
layers/+chat/erc/local/erc-tex/erc-tex.el
layers/+completion/helm/local/helm-spacemacs-help/helm-spacemacs-help.el
layers/+completion/ivy/local/ivy-spacemacs-help/ivy-spacemacs-help.el
layers/+distributions/spacemacs-base/local/help-fns+/help-fns+.el
layers/+distributions/spacemacs-bootstrap/packages.el
layers/+spacemacs/spacemacs-ui/local/info+/info+.el
layers/+spacemacs/spacemacs-ui-visual/local/zoom-frm/frame-cmds.el
layers/+spacemacs/spacemacs-ui-visual/local/zoom-frm/frame-fns.el
duianto commented 4 years ago

The first one: core/core-configuration-layer.el seems to already be using cl-lib https://github.com/syl20bnr/spacemacs/blob/cab1e69585f7ad47613e45d7123ebfe64bba0a7e/core/core-configuration-layer.el#L13

I'm unable to find an instance of 'cl in that file.

But here's some more files that also use 'cl:

./layers\+emacs\org\local\org-async-init.el:9:(require 'cl)
+distributions\spacemacs-docker\deps-install\lib\deps-install-helpers.el:12:(require 'cl)
./layers\+misc\ietf\local\irfc\irfc.el:336:(eval-when-compile (require 'cl))
./layers\+lang\python\local\nose\nose.el:56:(require 'cl) ;; for "reduce"
./layers\+lang\python\local\pylookup\pylookup.el:30:  (require 'cl)

It seems like functions/macros have been renamed in cl-lib to use thecl-` prefix, so maybe we would have to find and rename them.

source: https://emacs.stackexchange.com/questions/48109/require-cl-or-require-cl-lib

equwal commented 4 years ago

It seems like functions/macros have been renamed in cl-lib to use thecl-` prefix, so maybe we would have to find and rename them.

Yes, this is the purpose of the deprecation.

emacs18 commented 4 years ago

After above PR was checked in only one reference to cl package remain:

(eval-when-compile (when (< emacs-major-version 21) (require 'cl)))

I did not remove this, because this can be removed when a sweep is done to remove all checks of emacs-major-version for versions older than 25.1 which is the minimum required version for spacemacs.

Thus I think this issue can now be closed.

equwal commented 4 years ago

Yay, we did it.

hyiltiz commented 4 years ago

Hmm, I am still getting this error though I am in develop. I am using the following layers/packages.

   dotspacemacs-configuration-layers '(
     ;; ----------------------------------------------------------------
     ;; Example of useful layers you may want to use right away.
     ;; Uncomment some layer names and press `SPC f e R' (Vim style) or
     ;; `M-m f e R' (Emacs style) to install them.
     ;; ----------------------------------------------------------------
     ;; helm
     ivy
     gtags
     ibuffer
     auto-completion
     better-defaults
     ;; backup
     (shell :variables
            shell-default-height 30
            shell-default-position 'bottom)
     ;; toolchains
     git
     ess
     ;; ipython-notebook
     pandoc
     spell-checking
     syntax-checking
     version-control
     pdf ;; use our manually installed version
     semantic
     typography
     finance
     erc
     (ranger :variables ;; a vim-like file manager
             ranger-show-preview t
             ranger-show-hidden t
             ranger-cleanup-eagerly t
             ranger-cleanup-on-disable t
             ranger-ignored-extensions '("mkv" "flv" "iso" "mp4"))
     ;; themes-megapack
     ;; programming languages
     shell-scripts
     emacs-lisp
     octave
     haskell
     go
     (latex :variables latex-enable-folding t)
     lua
     python
     scheme
     ruby
     javascript
     purescript
     vimscript
     ;; markup languages
     (org :variables org-enable-reveal-js-support t)
     markdown
     html
     graphviz
     yaml
     csv
     )

   ;; List of additional packages that will be installed without being
   ;; wrapped in a layer. If you need some configuration for these
   ;; packages, then consider creating a layer. You can also put the
   ;; configuration in `dotspacemacs/user-config'.
   dotspacemacs-additional-packages
   '(
     org-pdfview
     org-ref
     org-mind-map
     rainbow-mode
     dired-rainbow
     dired-hacks-utils
     dired-narrow
     dired-subtree
     ivy-bibtex
     ivy-rtags
     all-the-icons-dired
     all-the-icons-ibuffer
     all-the-icons-ivy
     counsel-org-clock
     counsel-projectile
     counsel-tramp
     eval-in-repl
     ;;diff-hl ; somehow doesn't get installed :(
     speech-tagger
     password-store
     poly-R
     writegood-mode
     zotxt
     wttrin
     bongo
     ac-octave
     evil-multiedit
     evil-string-inflection
     evil-smartparens
     doom-themes
     ;;madhat2r-theme
     ;;solarized-theme
     ;; styles for writing
     poet-theme ; best in (leuven, humanoid, parchment)
     humanoid-themes
     ;;leuven-theme ; statusbar is too strong
     ;; parchment-theme ; comments are too strong
     ujelly-theme
     jbeans-theme
     );;
duianto commented 4 years ago

What's the error message your seeing?

equwal commented 4 years ago

Those are a lot of packages. I bet one of them is the culprit, and so the onus is on them. @hyiltiz should bisect those until he determines which one is the problem, or if it is in the core. If it isn't in the core, he should go elsewhere.

I'm not reopening this unless the problem is in a core layer.

hyiltiz commented 4 years ago

Testing for core is as simple as using a blank/fresh Spacemacs installation, right?

equwal commented 4 years ago

Testing for core is as simple as using a blank/fresh Spacemacs installation, right?

Yes. and fresh .spacemacs. However, some layers are part of the spacemacs core, so they also should be maintained here in this repository.

hyiltiz commented 4 years ago

I see quite a few layers that belong to that category:

(develop|✔)> ag "require 'cl\)"
ess-20200115.225/ess-tracebug.el
47:    (require 'cl))

srefactor-20180703.1810/srefactor-ui.el
44:  (require 'cl))

company-go-20190203.19/company-go.el
17:  (require 'cl))

popwin-20200122.1440/popwin.el
63:(eval-when-compile (require 'cl))

geiser-20200204.1826/geiser-gambit.el
32:(eval-when-compile (require 'cl))

geiser-20200204.1826/geiser-racket.el
25:(eval-when-compile (require 'cl))

geiser-20200204.1826/geiser-guile.el
27:(eval-when-compile (require 'cl))

geiser-20200204.1826/geiser-mit.el
21:(eval-when-compile (require 'cl))

geiser-20200204.1826/geiser-chibi.el
20:(eval-when-compile (require 'cl))

geiser-20200204.1826/geiser-syntax.el
20:(eval-when-compile (require 'cl))

geiser-20200204.1826/geiser-chicken.el
27:(eval-when-compile (require 'cl))

geiser-20200204.1826/geiser-chez.el
20:(eval-when-compile (require 'cl))

geiser-20200204.1826/geiser-company.el
20:(eval-when-compile (require 'cl))

js2-mode-20200211.2057/js2-imenu-extras.el
36:  (require 'cl))

ws-butler-20170111.2334/ws-butler.el
58:  (require 'cl))

eval-sexp-fu-20191128.825/eval-sexp-fu.el
122:(eval-when-compile (require 'cl))

spinner-1.7.3/spinner.el
101:  (require 'cl))

rvm-20150402.1442/rvm.el
42:(eval-when-compile (require 'cl))

slim-mode-20170728.1348/slim-mode.el
45:  (require 'cl))

volatile-highlights-20160612.155/volatile-highlights.el
199:  (require 'cl)

pytest-20181005.1524/pytest.el
68:(require 'cl)

golden-ratio-20191028.1732/golden-ratio.el
19:(eval-when-compile (require 'cl))

epc-20140610.534/epc.el
37:(eval-when-compile (require 'cl))

epc-20140610.534/epcs.el
27:(eval-when-compile (require 'cl))

font-lock+-20180101.1439/font-lock+.el
97:  (require 'cl) ;; incf

iedit-20190419.803/iedit-lib.el
52:(eval-when-compile (require 'cl))

iedit-20190419.803/iedit-rect.el
44:(eval-when-compile (require 'cl))

iedit-20190419.803/iedit.el
96:  (require 'cl)

fringe-helper-20140620.2109/fringe-helper.el
99:(eval-when-compile (require 'cl))

emmet-mode-20180613.341/emmet-mode.el
74:  (require 'cl))

ac-octave-20180406.334/ac-octave.el
51:(eval-when-compile (require 'cl))

fuzzy-20150730.337/fuzzy.el
29:(require 'cl)

erc-social-graph-20150508.1204/erc-social-graph.el
33:(require 'cl)

expand-region-20200106.2058/expand-region-core.el
29:(eval-when-compile (require 'cl))

open-junk-file-20161210.1114/open-junk-file.el
102:(eval-when-compile (require 'cl))

htmlize-20191111.2130/htmlize.el
86:(require 'cl)

ctable-20171006.11/ctable.el
45:(require 'cl)

auto-highlight-symbol-20130313.943/auto-highlight-symbol.el
244:  (require 'cl)

google-translate-20190620.1416/google-translate-core-ui.el
169:(eval-when-compile (require 'cl))

google-translate-20190620.1416/google-translate-core.el
66:(eval-when-compile (require 'cl))

ox-pandoc-20180510.1338/ox-pandoc.el
38:  (require 'cl))

persp-mode-20190511.1402/persp-mode.el
77:(require 'cl)

json-reformat-20160212.853/json-reformat.el
51:(eval-when-compile (require 'cl))

log4e-20170401.1304/log4e.el
70:(eval-when-compile (require 'cl))

org-plus-contrib-20200212/ox-deck.el
48:(eval-when-compile (require 'cl))

org-plus-contrib-20200212/org-registry.el
67:  (require 'cl))

org-plus-contrib-20200212/ox-taskjuggler.el
148:(eval-when-compile (require 'cl))

org-plus-contrib-20200212/ox-groff.el
40:(eval-when-compile (require 'cl))

org-plus-contrib-20200212/org-notify.el
60:(eval-when-compile (require 'cl))

org-plus-contrib-20200212/ox-s5.el
58:(eval-when-compile (require 'cl))

org-plus-contrib-20200212/ob-tcl.el
34:(eval-when-compile (require 'cl))

org-plus-contrib-20200212/org-depend.el
159:  (require 'cl))

org-plus-contrib-20200212/org-toc.el
36:  (require 'cl))

org-plus-contrib-20200212/org-learn.el
38:  (require 'cl))

org-plus-contrib-20200212/org-invoice.el
55:  (require 'cl)

org-plus-contrib-20200212/org-wikinodes.el
28:  (require 'cl))

org-plus-contrib-20200212/org-choose.el
66:                                     ;   (require 'cl))
67:(require 'cl)

gnuplot-20191212.1801/gnuplot.el
349:(eval-when-compile (require 'cl))

gnuplot-20191212.1801/gnuplot-gui.el
88:(require 'cl)

gnuplot-20191212.1801/gnuplot-context.el
250:  (require 'cl)

highlight-parentheses-20180704.1102/highlight-parentheses.el
40:(eval-when-compile (require 'cl))

git-gutter-fringe+-20140729.1103/git-gutter-fringe+.el
29:  (require 'cl))

auto-dictionary-20150410.1610/auto-dictionary.el
78:(eval-when-compile (require 'cl))

zotxt-20200120.1950/org-zotxt.el
29:  (require 'cl))

zotxt-20200120.1950/zotxt.el
30:  (require 'cl))

writegood-mode-20180525.1343/writegood-mode.el
69:  (require 'cl))

dash-20200119.2310/dash.el
40:    (require 'cl)))
duianto commented 4 years ago

Those are Emacs packages, which Spacemacs doesn't control.

Removing the cl package dependency will have to be handled by each package.

A Spacemacs layer is a collection of packages and configurations.

Here's the current list of Spacemacs layers on the develop branch: https://github.com/syl20bnr/spacemacs/blob/develop/layers/LAYERS.org

hyiltiz commented 4 years ago

Hmm, so if a spacemacs layer imports a bunch of packages that rely on cl, it should be those dealt with by those packages themselves, not the spacemacs layer that imported them, right? For example, it seems all those packages except zotxt are imported by some spacemacs layers, because I did not add them via dotspacemacs-additional-packages myself.

duianto commented 4 years ago

Hmm, so if a spacemacs layer imports a bunch of packages that rely on cl, it should be those dealt with by those packages themselves, not the spacemacs layer that imported them, right?

Correct, it should be handled upstream in each package.

If the package maintainers aren't aware of the cl deprecation and no one informs them about it, then they will learn about it when Emacs 27 is released, because it shows a message on startup, when there are packages that use cl:

Package cl is deprecated

hyiltiz commented 4 years ago

Yes, that is the message I am seeing as well; guess it will be noticed once Emacs 27 is released.

ericdallo commented 4 years ago

About dash.el in the list above: https://github.com/magnars/dash.el/issues/335

mjsteinbaugh commented 4 years ago

I'm seeing a "Package cl is deprecated" warning pop up with Emacs 27.1 and current spacemacs on develop branch. Any ideas on how to debug?

santiyounger commented 4 years ago

I'm seeing a "Package cl is deprecated" warning pop up with Emacs 27.1 and current spacemacs on develop branch. Any ideas on how to debug?

Exact same situation for me after updating to Emacs 27.1 with spacemacs on dev branch as well! As I see from @duianto explanation this doesn't seem to be much of a spacemacs problem, but more from individual packages, does this create any conflicts or issues in usability?

emacs18 commented 4 years ago

No. This is just a warning to remind developers that they need to migrate from old to new code. Everything should still work fine.

How to debug? Let me answer this by sharing what I just did with org-mode.

First I searched all my installed emacs packages for "require 'cl\)" using SPC s d command. There were 53 matches 14 of which came from org-plus-contrib package. So I resolved all 14 by

  1. Visit a file.
  2. Comment out (require 'cl) line.
  3. Byte-compile the file by (a) visiting dired buffer via SPC j d, then (b) typing B to byte compile the file in question.
  4. Resolve all warnings one by one, e.g., replace position with cl-position as instructed by the byte compiler.
  5. Replace (require 'cl) with (require 'cl-lib).
  6. Repeat for other files.

I emailed the resulting patch to org mode mailing list. Part of the patch I emailed is shown below.

diff --git a/contrib/lisp/org-depend.el b/contrib/lisp/org-depend.el
index 263cd7175..6d0aaba2e 100644
--- a/contrib/lisp/org-depend.el
+++ b/contrib/lisp/org-depend.el
@@ -155,8 +155,7 @@
 ;;

 (require 'org)
-(eval-when-compile
-  (require 'cl))
+(eval-when-compile (require 'cl-lib))

 (defcustom org-depend-tag-blocked t
   "Whether to indicate blocked TODO items by a special tag."
@@ -281,13 +280,13 @@ This does two different kinds of triggers:
                  (from-bottom items)
                  ((or from-current no-wrap)
                   (let* ((items (nreverse items))
-                     (pos (position this-item items :key #'first))
-                     (items-before (subseq items 0 pos))
-                     (items-after (subseq items pos)))
+                     (pos (cl-position this-item items :key #'first))
+                     (items-before (cl-subseq items 0 pos))
+                     (items-after (cl-subseq items pos)))
                 (if no-wrap items-after
                   (append items-after items-before))))
                  (t (nreverse items))))
-         (setq items (remove-if
+         (setq items (cl-remove-if
                   (lambda (item)
                 (or (equal (first item) this-item)
                     (and (not todo-and-done-only)

diff --git a/contrib/lisp/org-wikinodes.el b/contrib/lisp/org-wikinodes.el
index e44ac9870..bc35a1a41 100644
--- a/contrib/lisp/org-wikinodes.el
+++ b/contrib/lisp/org-wikinodes.el
@@ -25,7 +25,7 @@

 (require 'org)
 (eval-when-compile
-  (require 'cl))
+  (require 'cl-lib))

 (defgroup org-wikinodes nil
   "Wiki-like CamelCase links words to outline nodes in Org mode."
@@ -154,7 +154,7 @@ setting of `org-wikinodes-create-targets'."
        ((stringp create)
    ;; Make new node in another file
    (org-mark-ring-push (point))
-   (org-pop-to-buffer-same-window (find-file-noselect create))
+   (pop-to-buffer-same-window (find-file-noselect create))
    (goto-char (point-max))
    (or (bolp) (newline))
    (insert "\n* " target "\n")
@@ -279,8 +279,8 @@ with working links."
     (while (re-search-forward re nil t)
       (unless (save-match-data
        (or (org-at-heading-p)
-           (org-in-regexp org-bracket-link-regexp)
-           (org-in-regexp org-plain-link-re)
+           (org-in-regexp org-link-bracket-re)
+           (org-in-regexp org-link-plain-re)
            (org-in-regexp "<<[^<>]+>>")))
    (setq link (match-string 0))
    (delete-region (match-beginning 0) (match-end 0))
hyiltiz commented 4 years ago

The process described by @emacs18 seem like it is possible to automate; it would be awesome if Spacemacs has some "doctor" utility that could traverse all installed packages producing that cl warning, perform the described procedure until the warning is gone. For a longer term solution, maybe even submit patches automatically to the authors of those packages.

santiyounger commented 4 years ago

@emacs18 Thank you for the detailed solution, I appreciate the help!

YaoLiMuMu commented 4 years ago

@emacs18 it always works fine except popwin.el

emacs18 commented 4 years ago

I submitted https://github.com/emacsorphanage/popwin/pull/144 PR to fix popwin.el. The PR was merged in less than two minutes as https://github.com/emacsorphanage/popwin/commit/5a828c5b2bba5fec5fb62df8cfa86bff21af530e !

jonhermansen commented 3 years ago

I still get the warning when starting fresh Emacs 27.1 on tip of Spacemacs develop branch

It seems that there are much less uses of it now:

$ grep --exclude='./elpa/*' -R "(require 'cl)" .
./core/libs/dash.el:    (require 'cl)))
./core/libs/mocker.el:  (require 'cl))
./layers/+spacemacs/spacemacs-visual/local/zoom-frm/frame-fns.el:(eval-when-compile (when (< emacs-major-version 21) (require 'cl)))
sumitkumar97 commented 3 years ago

@hyiltiz I was also getting this error on develop branch. It went away after removing emacs-lisp layer.

whompyjaw commented 2 years ago

I am also still getting the issue. Spacemacs develop, and Emacs 27.2 (compiled from source tho, so maybe i could have missed something) on WSL2 ubuntu.

lebensterben commented 2 years ago

@saltsucker

Some upstream packages are still using deprecated API and is not within our control.

whompyjaw commented 2 years ago

@saltsucker

Some upstream packages are still using deprecated API and is not within our control.

Ah okay, thanks!

halostatue commented 2 years ago

I’m seeing this here:

layers/+spacemacs/spacemacs-visual/local/zoom-frm/zoom-frm.el
235:(eval-when-compile (require 'cl)) ;; case

layers/+spacemacs/spacemacs-visual/local/zoom-frm/frame-fns.el
83:(eval-when-compile (when (< emacs-major-version 21) (require 'cl)))

layers/+spacemacs/spacemacs-visual/local/zoom-frm/frame-cmds.el
607:(eval-when-compile (require 'cl)) ;; case, incf (plus, for Emacs 20: dolist, dotimes)

The first is found at https://www.emacswiki.org/emacs/zoom-frm.el, https://github.com/emacsmirror/emacswiki.org/blob/master/zoom-frm.el, and https://github.com/emacsmirror/zoom-frm/blob/master/zoom-frm.el. I believe that if someone were to edit zoom-frm.el emacswiki it would update the Git repos.

The middle can be ignored (it only applies to very old versions of emacs).

The last is found at https://www.emacswiki.org/emacs/frame-cmds.el, https://github.com/emacsmirror/frame-cmds, and https://github.com/emacsmirror/emacswiki.org/blob/master/frame-cmds.el. The same applies above.

However, since these are essentially pulled from the wiki, wouldn't it make sense just to adopt them in spacemacs since they're not upstream packages as such?