reddit / emacs

Did I install it correctly?

DiamondDemon669 · 2022-04-09 17:58
So dired has this problem where directories open in new buffers. The wiki said dired+ had a command to fix it, but I did not know how to install it so I just copied the dired+.el file into the /usr/share/emacs/28.1/lisp directory. when I did `(require 'dired+.el)` it worked but all the other things had .elc or .gz files and I'm not sure if I need that
zixx999 · 2022-04-09 18:09
Usually you can install it in *your* user's home folder. Just drop it in ~/.emacs.d/ or something like that, I forget the exact name of the directory
xtifr · 2022-04-09 18:44
Regarding your original problem: if you use 'i' to open a directory in regular dired, it opens (inserts) it in the current buffer along with the parent dir.
big_lentil · 2022-04-09 18:52
>So dired has this problem where directories open in new buffers As of 28.1 you can change that behavior without installing any package by the following (setq dired-kill-when-opening-new-dired-buffer t) Also .elc files are byte-compiled lisp code and those will be generated automatically, and .gz files are compressed stuff that probably just came as part of the installation (couldn't find them in my own install though) As for installing things manually require can find them as long as the file is in your load-path, check C-h f require and C-h v load-path for the documentation.
ftrx · 2022-04-09 19:03
There are various way to "install packages", witch are just elisp in general, so just text you can even load evaluating the file directly. My suggestion is starting with the built-in package.el witch offer a UI, just run `M-x list-packages` after having a small "repository setup" like (require 'cus-edit) (customize-set-variable 'load-prefer-newer t "Prefer .el files if newer than .elc ones.") (customize-set-variable 'package-archives '(("gnu" . "https://elpa.gnu.org/packages/") ("nongnu" . "https://elpa.nongnu.org/nongnu/") ("gnu-devel" . "https://elpa.gnu.org/devel/") ("melpa" . "https://melpa.org/packages/"))) (package-initialize) (unless package-archive-contents (package-refresh-contents)) then to make a more comfy install and setup directly from the config you might want to add also (customize-set-variable 'package-check-signature nil "Some pkgs. do have signature issues...") (unless (package-installed-p 'use-package) (package-install 'use-package)) (require 'use-package) (customize-set-variable 'use-package-always-ensure t "Install a defined pkg if not installed.") and then you are able to auto-install and configure any package just with sexps like (use-package a-package-name) adding `:config` blocks etc. For manually installed packages I prefer `~/.emacs.d/mypkgs/` a subdir/repo per package. You just need to add those dirs to the load path without use-package with something like (add-to-list 'load-path "~/.emacs.d/mypkgs/apkg") (require 'apkg) or with use-package (use-package apkg :ensure nil :load-path "~/.emacs.d/mypkgs/apkg") You might like a wrapper script to upgrade those manually installed packages etc, while keeping them in emacs distribution probably means having them erased by a system package manager upgrade. In any case remember that in Emacs code is just text surrounded by (), witch is called a sexp, you can run it directly with the point (focus/cursor) at the closed parentheses hitting C-x C-e (control+x followed by control+e witch is bound in general to `eval-last-sexp` because anything is a function (a command is just a function marked "interactive") and any function can be bound to any key you like and called as you like. "Installing" here means just put a small set of sexps, typically saved in one or more .el text files, somewhere on the disk and load them. Not much different than run `M-x eval-buffer` in the visited (opened) file (witch is a buffer, actually). In lisp code and data are just text, you can intermix them thanks to the quasiquote construct, run everywhere, save and recall in any form etc. And that means there is no difference between official "upstream emacs" code, a third party package or your own code. A package just collect code under a common name so you can load it just require-ing the name. Emacs will look for it in it's load path.
Hamilton950B · 2022-04-09 22:37
That's what I do. It has the advantage that you don't lose them when you upgrade emacs.
7890yuiop · 2022-04-09 23:16
> So dired has this problem where directories open in new buffers. It has the same "problem" where files open in new buffers! If you want to replace the dired buffer, use `a` on the thing you're opening. It's your choice -- dired just does what you ask it to do. ---- And you've gotten some over-complicated answers to your other question... > I just copied the `dired+.el` file into the `/usr/share/emacs/28.1/lisp` You would typically add it to your personal config. I suggest this: mkdir -p ~/.emacs.d/lisp mv dired+.el ~/.emacs.d/lisp/ Then in your init file: (add-to-list 'load-path (expand-file-name "~/.emacs.d/lisp")) (require 'dired+) Note in particular that you should not put it *directly* in `~/.emacs.d` (and Emacs would complain if you added that directory to `load-path`); hence the `lisp` sub-directory (although you could name it anything). > All the other things had .elc or .gz files and I'm not sure if I need that You don't need to compress anything (although Emacs can open it seamlessly if you do), but you would generally want to byte-compile the library (i.e. generate the `.elc` file). You can do that with `M-x byte-compile-file`. See `C-h i g (elisp)Byte Compilation` for all the details.
flexibeast · 2022-04-09 23:18
Just another reminder that `use-package` is *not* part of stock Emacs (including 28.1).
Danrobi1 · 2022-04-10 00:10
Yep 'i' (dired-maybe-insert-subdir) to open and 'I' (dired-kill-subdir) to kill. Happy cake day!
JohnDoe365 · 2022-04-10 03:10
Btw. (setq dired-kill-when-opening-new-dired-buffer) works great, using it since a couple of days and I only have one dired buffer all the time
Phil-Hudson · 2022-04-10 08:15
Best answer, by some distance. Just to add: never\* touch anything under /usr/share/emacs. That is assumed to be under system management, and as u/Hamilton950B hinted anything you place there may be overwritten or deleted by the system during upgrades. \*There are in fact some advanced, specialized legitimate exceptions.
ftrx · 2022-04-10 10:38
Thanks, I know that while not really why (here there was some polemics but not about what), anyway as pasted I've added the sexp to install it if not already installed. Effectively Emacs have various ways to manage code but package.el + use-package IME are the best combo, built-in for browsing, upgrading etc and use-package to ease the config dividing it in separate sexps so that's easy add/remove/activate/deactivate them immediately. I've tried el-get, it's nice but after a bit of heavy usage issues start to appear, borg again nice for some aspects but... straight, nice but grab directly from git repos HEAD means often instability, package.el nice but do almost nothing to help configuration side...