Questions tagged [filenames]

54 questions
8
votes
1 answer

How do I unexpand a file name?

Given ~/foo/bar, I can get /home/sds/foo/bar using expand-file-name. However, given /Users/sds/foo/bar, how do I get ~/foo/bar? Use case: I want to copy a file between computers and they have different physical paths to my home directory.
sds
  • 5,928
  • 20
  • 39
5
votes
1 answer

Automatically Uniquify Certain Buffers

Emacs does a wonderful job of disambiguating buffer names when I have several files with the same name open. That is, if I open a single main.cpp, the buffer is simply called main.cpp, but if I open two of them, then one will be main.cpp and…
5
votes
4 answers

How to duplicate a file in Dired?

Let's say I have the following file shown in Windows File Explorer: If I enter C-c C-v to copy and paste the file, the file is duplicated and automatically given a name: We can repeat this to get more duplicates which are also automatically…
dharmatech
  • 1,212
  • 7
  • 19
3
votes
1 answer

Abbreviate "/home/user/file" to "~/file" in formatted fields (frame-title-format, etc.)

I have Emacs display the full path of the file in my window title: (setq-default frame-title-format '("%f [%m] - Emacs")) And in my mode-line: (setq-default mode-line-buffer-identification (list 'buffer-file-name …
yPhil
  • 963
  • 5
  • 22
3
votes
1 answer

How to map or iterate over a list of files and set the result to `org-agenda-files`?

looking for a little help with my function. I'm trying to create a loop-while that'll return a list of files back to org-agenda-files. It's just not working though and i keep getting errors. Any ideas how I can get this to work? Any using a…
3
votes
2 answers

How to test if absolute path is a root file/directory

Q:  How to test whether an absolute path is a root file/directory (e.g., at the first level of the hard drive)? I see a few possibilities depending upon whether the file is on Windows or Unix/Linux. Here is my first attempt: (equal "/bar" (concat…
lawlist
  • 18,826
  • 5
  • 37
  • 118
3
votes
2 answers

Why does thing-at-point not consider plus as a filename character?

Why does thing-at-point not consider + as a filename character? For example: (defun my-get-filename-at-point () (interactive) (message (thing-at-point 'filename t))) and consider the cursor positioned at the filename bookmark+-1.el in the…
Håkon Hægland
  • 3,608
  • 1
  • 20
  • 51
3
votes
2 answers

Increment file name and create a new version of the file

Assume that I am working with a file whose name contains a unique version number for example myfile_03.tex or 03jhcjh.tex and so on. Currently I create a new version of the file by C-x C-w and incrementing the number manually. To be precise I would…
Name
  • 7,689
  • 4
  • 38
  • 84
2
votes
1 answer

How can I construct a bash-safe filename from a string?

I want to generate very simple filenames from complex strings during a org-capture. For instance the string "Une idée nouvelle pour calculer $\\int_0^{\\infty} e^{-t^2} \\dd t$" Should be reduced…
B. Pillet
  • 41
  • 3
2
votes
1 answer

How to resolve a form before use

I have a form variable which contains a list of file paths specified via functions: (defcustom my-files-form '(append (list (concat my-root ".emacs") (concat my-root ".custom")) (file-expand-wildcards…
halloleo
  • 1,215
  • 9
  • 23
2
votes
2 answers

Why does emacs recognize my wildcard with finding file but not with searching buffer?

In the linux terminal, i often use wildcards (*) as a shorter alternative to type in the whole file name: if the file is named foo-and-cats I just type in something like fo* in order to pull up the file. This trick also works when i use emacs to…
2
votes
0 answers

Is there a predefined way to detect if a file is a Unix socket?

Are there predefined Emacs functions to check if a file is a Unix socket? The best I could come up with is the following code. (defun socket-p (fname) "Return non-nil if FNAME is a Unix Socket, nil otherwise." (eq (string-to-char (nth 8…
PRouleau
  • 744
  • 3
  • 10
2
votes
1 answer

Modify the first element of the kill-ring

I have stored in my clipboard a path to an image, which I want to paste inside emacs. I would like to modify the path to change/postpone/prepone some stuff before yanking. Following my previous question here, I tried (defun replace-in-string (what…
user1683620
  • 103
  • 6
2
votes
1 answer

Rename org buffers to org's +TITLE instead of filename

I have hundreds of org files in a single directory that I use as a personal knowledge base and use deft to quickly find and open them. Each file is automatically named based on the current time (yyyy-mm-dd-hhmm.org) but Deft displays the org file's…
Ryan West
  • 23
  • 3
2
votes
1 answer

Magit diff with --name-only?

I am browsing the differences between two branches of a repository via git diff --name-only branch1 branch2 I also use the --name-status option sometimes, since I may need to see what sort of difference there is for a given file. Plodding along…
GDP2
  • 1,340
  • 9
  • 25
1
2 3 4