5

make-temp-file can be used to make a directory instead of a file, this example simply calls make-temp-file, then removes the directory afterwards. (let ((temp-dir (make-temp-file "foo" t))) (unwind-protect (progn ;; do stuff ) (delete-directory temp-dir t))) This same functionality as a macro: (defmacro with-temp-dir (temp-dir &...


4

Just use relative directory name (setq backup-directory-alist '(("." . "editorbackups"))) Function make-backup-file-name-1 will make directory name relative to file's directory and create it: ;; If backup-directory is relative, it should be relative to the ;; file's directory. By expanding explicitly here, we avoid ;; depending on default-directory. (if ...


4

Try C-u M-! and inserting the output from commands below that I adopted from another question / Answer find . |sort|sed -E -e 's;(^.*[^/]/);\1 ;;s;([^/]*/);*;g;s/^\.$//' That will give you a directory listing as headings, for example * dir1 ** file1 ** file2 * dir2 ** file1 * dir3 Select the region and convert headings to a lists using C-c - - dir1 - ...


4

You can define a variable in the script that records the directory: (defvar my-shell-directory (if load-file-name (file-name-directory load-file-name) default-directory)) You can then use it in your own functions: (defun my-shell-command (cmd) (shell-command (expand-file-name cmd my-shell-directory)))


3

;; Inspired from `dired-create-directory` code. (defun with-temp-dir (dir) "..." (let* ((expanded (directory-file-name (expand-file-name dir))) (try expanded) new) (unwind-protect (progn (when (file-exists-p expanded) (error "Cannot create directory %s: file exists" expanded)) ;; Find ...


3

You can try using C-M-j, as explained here Q: How do I enter an input that matches one of the candidates instead of this candidate? Example: create a file bar when a file barricade exists in the current directory. A: Press C-M-j. Alternatively, you can make the prompt line selectable with (setq ivy-use-selectable-prompt t).


2

Yes, there is. If you append a forward slash (/) after your directory name, ivy-mode will be forced to treat it as a directory path.


2

By modifying the line: (let ((default-directory (get-compass-root-dir)))) to (setq default-directory (get-compass-root-dir)) I get the desired result. I picked the 'let' code up from scouring other similar natured questions on the interweb, but in this instance it caused an issue. Dont ask me why - im really shooting in the dark with elisp at the minute! ...


2

fA.cpp fB.cpp fC.cpp No-frills approach in Dired: %m f[A-Z]\.cpp RET to mark files t to invert the marks k to hide the marked files


2

If you provide a directory on the command-line, it opens in dired mode. For example emacs . ...will open the current directory in dired mode. The variable `dired-listing-switches' contains the switches sent to the ls command. So adding (setq dired-listing-switches "-lart") to your startup config (or customizing it) should do what you want. You can ...


2

There is command cd: M-x cd (or bind it to a key). There is also Dired: C-x d, then C-h m. Or C-h r g dired, which takes you to node Dired of the Emacs manual. Both of those should help you. See also variable default-directory, using C-h v. C-h f cd tells you this: cd is an interactive compiled Lisp function in files.el. (cd DIR) Make DIR ...


2

(cl-remove-if-not #'file-directory-p (directory-files-recursively "name-of-directory" "autoload" t)) directory-files-recursively seems not well-known for some reason. See Directories for a fuller explanation.


2

Not exactly sure what you're asking, but perhaps this will help. Offhand, a guess is that bookmarking Dired buffers is close to what you are looking for. Dired itself lets you have a Dired buffer that contains (only) a given set of files and directories - from anywhere in your file system. You do this by passing a list of them to function dired. See C-h f ...


2

The code below uses a new feature in 26.1 called variable-watcher. It allows a function to observe changes in some variable's value. But more or less the same could be achieved by using hooks and/or advices covering all standard functions which are changing the directory (e.g. find-file-hook). There may be unforeseen consequences to this. ;; -*- lexical-...


1

Emacs manual node Action Arguments tells you this about command-line option --load: Load a Lisp library named FILE with the function load. If FILE is not an absolute file name, Emacs first looks for it in the current directory, then in the directories listed in load-path (*note Lisp Libraries::). Warning: If previous command-line arguments ...


1

Emacs packages will automatically find the project root, company-gtags (for code completion) from https://github.com/company-mode/company-mode counsel-git-grep (for grepping) and counsel-git (for finding file) from https://github.com/abo-abo/swiper IMO, workspace is an outdated idea. Everything should just work out of box without setup. BTW, unlike ...


1

I use shell pop to do what I think you are asking for. When I press Ctrl-t, it splits the window, creating a new buffer with a shell in that buffer set to the directory that matches the directory of the buffer I started in. When I press Ctrl-t again, it closes the window and shell it had opened.


1

You can use the ls command of the built-in eshell for listing the files with some predefined depth. You have to specify the depth by the right number of concatenated file name generator expressions */. Example: (split-string (substring-no-properties (eshell-command-result "ls /usr/share/emacs/26.1/*/*/*/*/*/*(.)") ) "\n" t) The appended modifier (.)...


1

Library find-dired+.el can help with this. C-h f find-dired: find-dired is an interactive compiled Lisp function in find-dired+.el. (find-dired DIR ARGS &optional DEPTH-LIMITS EXCLUDED-PATHS) Run find and put its output in a buffer in Dired Mode. Then run find-dired-hook and dired-after-readin-hook. The find’ command run (after ...


1

The elgrep-search command has options :mindepth and :maxdepth. Elgrep is available via package-install from the melpa package archive (instructions how to add melpa to package-archives can be found on the melpa "Getting Started" page). You can use elgrep as follows to get a list of matching file names of a specific depth. In the example I search in my HOME-...


1

I'd be inclined to use find for that: (let ((dirname (expand-file-name "~/")) (depth 3)) (split-string (shell-command-to-string (format "find %s -mindepth %d -maxdepth %d -type d -print0 2>/dev/null" (shell-quote-argument dirname) depth depth)) "\0" :omit-nulls)) n.b. -mindepth, -maxdepth, and print0 are not POSIX options, ...


1

It looks like you are trying to save the file ~TUTORIAL at the root of the system (/) instead of saving the file TUTORIAL in your home directory (~/). Typically when you open a new file Emacs will suggest directory based on the active buffer; however that is only a suggestion and you can always delete it, and enter something else. Emacs itself is not ...


1

Install https://github.com/technomancy/find-file-in-project (available at http://melpa.org) M-x find-file-in-current-directory or find-file-in-project-by-selected or find-file-in-project you got interactive UI to filter candidates. The UI is based on ivy (https://github.com/abo-abo/swiper), so you could input keyword1 keyword2 to tweak the final result (...


1

You can use org-fstree (install from MELPA or from here). It seems to do exactly what you want, it even makes each heading be a link to the corresponding file or folder. To use it, just put a line #+BEGIN_FSTREE: ~/path/to/folder in your org file and type C-c C-c on it. This will create a copy of the directory tree mapped to nested org headlines. A ...


1

directory-files accepts match-regexp argument: (directory-files "my/path/to/dir" nil "^[0-9][0-9.]*$") should return ("4.03.0" "4.02.9") and you extract the first element of the list using functions first or car. If you really want to use seq-remove, you can do that too: (seq-remove (lambda (s) (not (string-match "^[0-9][0-9.]*$" s))) '("." ".." "4....


1

To open a directory at startup you can also insert (find-file "/path/to/dir") in init.el


1

If you are on MS Windows, consider using this simple way: Create a Windows shortcut, with: runemacs.exe (with its path), in field Target. Include any command-line switches you like - e.g., D:\Emacs-25.1\bin\runemacs.exe --debug-init The directory you want Emacs to start in, in field Start in. You can also have Emacs start out by visiting that directory ...


1

Oops, never mind, I read the link I provided earlier again and I finally got how to turn it into an ~/.emacs modification. Specifically I added: (setq initial-buffer-choice "~/Documents/CodeLite/CPP-Math-Projects/Simple-Pendulum") to my ~/.emacs file.


1

Tramp must check whether the directory, you intend to create the new file in, does exist. This can be done only by checking on the remote host. Asking for the password is part of the connection to the remote host.


Only top voted, non community-wiki answers of a minimum length are eligible