Skip to content

Commit

Permalink
feat(link/add): Don't link when no -pkg.el file (#133)
Browse files Browse the repository at this point in the history
* feat(link/add): Don't link when no -pkg.el file

* Simplify link
  • Loading branch information
jcs090218 authored Mar 2, 2023
1 parent dfac98b commit 95cf898
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 23 deletions.
7 changes: 7 additions & 0 deletions lisp/help/link/add/error
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

💡 You need the `-pkg.el` file so the `package.el` can recognize your package.

Options are,

- [ ] Use `eask pkg-file` to create one
- [ ] Write your own `-pkg.el` file
2 changes: 0 additions & 2 deletions lisp/help/link/add → lisp/help/link/add/success
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@

✓ You have now created the link, here are things you might want to consider:

- [ ] `SOURCE-pkg.el` file Package descriptor
- [ ] (Optional) `SOURCE-autoloads.el` Package autoloads
- [ ] (Optional) Compile source package with `.elc` files Use `.elc` may be metter choice

If the source package uses Eask, you can use `eask` commands to accomplish these tasks.

* `eask pkg-file`
* `eask autoloads`
* `eask compile`
31 changes: 10 additions & 21 deletions lisp/link/add.el
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
(link-path (expand-file-name dir-name package-user-dir)))
(when (file-exists-p link-path)
(eask-with-progress
"!! The link already present; override the existing link... "
(ansi-yellow "!! The link already present; override the existing link... ")
(eask--delete-symlink link-path)
"done ✓"))
(ansi-yellow "done ✓")))
(make-symbolic-link source link-path)
(eask-msg "")
(eask-info "✓ Created link from %s to %s" source (eask-f-filename link-path))))
Expand All @@ -61,8 +61,7 @@
;; Create the link
(t
(let ((links (eask--links))
(pkg-el (expand-file-name (package--description-file source) source))
(pkg-eask (car (eask--all-files source)))
(pkg-el (expand-file-name (package--description-file name) source))
(pkg-desc))
(cond
((ignore-errors (file-exists-p pkg-el))
Expand All @@ -76,23 +75,13 @@
eask--link-package-version (package-version-join
(package-desc-version pkg-desc)))
;; XXX: Install dependencies for linked package
(eask--install-packages (eask--package-desc-reqs pkg-desc)))
((ignore-errors (file-exists-p pkg-eask))
(let ((deps))
(eask--save-load-eask-file pkg-eask
(progn
(setq eask--link-package-name (eask-package-name)
eask--link-package-version (eask-package-version))
(setq deps eask-depends-on))
(eask-error "✗ Error loading Eask-file: %s" pkg-eask))
;; XXX: Install dependencies for linked package
(eask-install-dependencies)))
(eask--install-packages (eask--package-desc-reqs pkg-desc))
(eask--create-link name source)
(when (and (zerop (length links)) ; if no link previously,
(= 1 (length (eask--links)))) ; and first link created!
(eask-help "link/add/success")))
(t
(eask-error "✗ Link source %s doesn't have an Eask or %s-pkg.el file"
source name)))
(eask--create-link name source)
(when (and (zerop (length links)) ; if no link previously,
(= 1 (length (eask--links)))) ; and first link created!
(eask-help "link/add")))))))
(eask-info "✗ (Missing `%s-pkg.el` file in your source folder)" name)
(eask-help "link/add/error"))))))))

;;; link/add.el ends here

0 comments on commit 95cf898

Please sign in to comment.