9

Use function abbreviate-file-name. C-h f says: abbreviate-file-name is a compiled Lisp function in `files.el'. (abbreviate-file-name FILENAME) Return a version of FILENAME shortened using `directory-abbrev-alist`. This also substitutes "~" for the user's home directory (unless the home directory is a root directory) and removes automounter prefixes (see ...


6

Don't name your file x-mode.el if it does not actually provide a mode of some sort: that seems confusing. If you are providing library x, just call the file x.el. From what I've seen, most modes (major or minor) do not actually use x-mode.el either. That naming convention is generally used in multi-file packages where the core functionality is implemented ...


4

Use quotes to make cd think /Nuskha/With Space/file is one single argument, not two, e.g., $ cd "/Nuskha/With Space/file" $ cd '/Nuskha/With Space/file' You can also use shell-quote-argument: (shell-quote-argument "/Nuskha/With Space/file") ;; => "/Nuskha/With\\ Space/file"


4

Not sure what you're asking, but perhaps this is it (from Dired+): (defun diredp-root-directory-p (file) "Return non-nil if FILE is a root directory." (if (fboundp 'ange-ftp-root-dir-p) (ange-ftp-root-dir-p (file-name-as-directory file)) ;; This is essentially `ange-ftp-root-dir-p' applied to `file-name-as-directory'. ;; If `ange-ftp-root-...


4

The behavior as described by you is the intended one. If you want only the remote pathname, you must call (file-remote-p (file-truename "./file.ext") 'localname)


4

Not sure why it's not in the default set of chars but you can add it yourself. The relevant variable is thing-at-point-file-name-chars. For example: (eval-after-load "thingatpt" (setq thing-at-point-file-name-chars (concat thing-at-point-file-name-chars "+")))


4

In dired, type C-xC-q to switch to editable dired mode. Start query-replace-regexp with C-M-% Enter \([^ ]+\)_\([0-9]+\).png as the search pattern, and \2_\1_.png as the replacement. Type y to replace a single instance, or ! to replace all instances. Type C-cC-c to save the changes.


4

Without looking up any of the Org variables or functions you refer to, here's a guess at what you're trying to do. They both do the same thing: iterate over a list of file names, expanding them in directory org-gtd-folder, and setting the value of variable org-agenda-files to the resulting list of absolute file names. ;; Use `mapcar' (setq org-agenda-files ...


3

I'd do (equal "COMMIT_EDITMSG" (file-name-nondirectory <file>))


3

For one thing (and I am not at all sure there isn't another problem), the call to expand-file-name in the macro body is scrambled. It should be (expand-file-name (concat ,module ".el") j/config-path) Also you may want to evaluate the concatentation at macro expansion time: (expand-file-name ,(concat module ".el") j/config-path) hope ...


3

The following code renames the buffer to the value of #+TITLE: when you open the Org file. This is the most simple version. It does not update the buffer name when you add or change the title. But in that case you can call org+-buffer-name-to-title directly if you really need it. (defun org+-buffer-name-to-title () "Rename buffer to value of #+TITLE:." (...


3

This should do more or less what you request. (defun dired-duplicate-this-file () "Duplicate file on this line." (interactive) (let* ((this (dired-get-filename t)) (ctr 1) (new (format "%s[%d]" this ctr))) (while (file-exists-p new) (setq ctr (1+ ctr) new (format "%s[%d]" this ...


3

The following elisp code should define a function write-file-increment doing what you want, except for the "preserving length" part. If the file name does not contain a number, it adds "-1". Apart from that case, the position of the number in the filename shouldn't matter. (defun tv/increment-number-in-file-name (name) (with-temp-buffer (insert name) ...


2

because in thingatpt.el the var thing-at-point-file-name-chars is defined: (defvar thing-at-point-file-name-chars "-~/[:alnum:]_.${}#%,:" "Characters allowable in filenames.") If you set it, that the + is added to the chars, like so: (setq thing-at-point-file-name-chars "-~/[:alnum:]_.${}#%,:+") then it works like you want it to.


2

Have you tried using org-link-unescape to get back the original filename? Something like: :face '(lambda (path) (if (file-exists-p (org-link-unescape path)) '(:foreground "green") '(:foreground "red"))))


2

M-x pp-macroexpand-last-sexp is your friend. It shows you the code that your macro is expanding into, which is: (with-eval-after-load (expand-file-name (concat "latex" ".el" j/config-path)) funcs) Which tells Emacs to evaluate the variable funcs (which probably won't exist) should it ever load a library </path/to/current/...


2

No. Emacs on MS Windows uses the GNU/Unix conventions of ~ and / as directory separator, just fine. See also the Emacs manual, nodes Minibuffer File and Windows HOME. (And on MS Windows be sure to define environment variable HOME.)


2

You can write your own function and bind it to F7 instead of binding dired-create-empty-file to it - something like this (lightly tested): (defun my-dired-create-empty-file () (interactive) (let* ((ts (format-time-string "%Y-%m-%dT%H.%M.%S" (current-time))) (fname (format "%s.org" ts))) (dired-create-empty-file fname) (find-file fname)))...


2

Mostly your problem was misplaces parens: too many ) here: (let ((tmp (car kill-ring)))) Use paren-mode to see which parens balances which parens. Standard function kill-new replaces the head of the kill-ring if you give it a second arg of non-nil. So (kill-new "xxx" t) replaces the head of the kill-ring with xxx. So try this: (defun foo () (...


2

Use function abbreviate-file-name. C-h f tells us: abbreviate-file-name is a compiled Lisp function in files.el. (abbreviate-file-name FILENAME) Return a version of FILENAME shortened using directory-abbrev-alist. This also substitutes ~ for the user's home directory (unless the home directory is a root directory) and removes automounter prefixes (see the ...


1

You can do this quite easily, and rather more flexibly, without defining any functions (and probably learning another way of using dired along the way). Mark the files you want to copy (if no files are marked, operate on the file at point.) "% C" (dired-do-copy-regexp) ".*" (copy from regexp) - specify a regexp matching the whole file ...


1

This answer is for using command icicle-find-file-absolute, which is similar in most regards to icicle-locate. But icicle-locate uses a prefix arg differently, passing it to system-command locate. So icicle-locate doesn't handle the use of a prefix arg to make multi-completion candidates include also a last modification-date middle component. (Command ...


1

Updating this to provide the short answer, after email exchange: Set user option icicle-file-sort to the sort order you want, e.g., icicle-case-string-less-p. (Leaving the rest of the original response, below, in case it helps someone.) I'm not sure what's going on, so this isn't much of an "answer", so far. You can follow up by email if this becomes a ...


1

This comes from ffap (find file at point), as the name might suggest. Specifically, find-file uses read-file-name to read its input, which in turn calls read-file-name-default unless overridden through the variable read-file-name-function. read-file-name-default calls the auxiliary function read-file-name--defaults to build the initial inputs: current ...


1

Hm, I am not so sure why you decide to sort "/1/2/3/4" before "/path/to/directory/file" in your desired result. If you can skip that specification the solution is rather simple: (let ((paths '("/path/to/different_directory/different_file" "/path/to/directory/file" "/X/Y" "/a/b/c/d/e/f" "/1/2/3/4" "/A/B/C/...


1

The diff popup doesn't (currently) support --name-only or --name-status. You could add them yourself with magit-define-popup-switch and the output will show, but the buffer won't be parsed correctly. You can achieve a similar output by calling magit-section-cycle-diffs (M-tab), but I'd guess you're trying to avoid including the diffs at all since you say ...


1

These files (COMMIT_EDITMSG, git-rebase-todo and others) are added to file-name-history by server-visit-files. It is possible to undo that by advising that function, and I have implemented that. But I am unsure whether that advise should also remove entries for these files that already existed prior to that function being called. I think so because those ...


1

(expand-file-name "./file.ext") => "/home/brian/file.ext"


1

Does your completion system/mode even support regexp matching? Vanilla Emacs completion does not, out of the box. At any rate, the patterns in completion-ignored-extensions are not regexps. They are not even filename glob patterns. They are literal text that file names must match at their ends. In particular, the . is not special, but matches a literal .. ...


1

The dot is not special in completion-ignored-extensions, so (push "_flymake.hs" completion-ignored-extensions) should do the job. If it doesn't, then I'd guess that it's either because completion-ignored-extensions is not used (or used incorrectly) by the completion system you're using, or because all the candidates would be eliminated by completion-...


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