[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Emacs Modular Configuration: the preferable way.
From: |
Jean Louis |
Subject: |
Re: Emacs Modular Configuration: the preferable way. |
Date: |
Tue, 22 Jun 2021 03:17:18 +0300 |
User-agent: |
Mutt/2.0.7+183 (3d24855) (2021-05-28) |
* Emanuel Berg via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org> [2021-06-22 03:04]:
> > In some functions it matters if you end filename with
> > a slash or not when you work with directories.
>
> I can imagine the situation but if it should do different
> things depending on if it is a directory or a regular file, it
> is better for these functions themselves to determine what it
> is, and not rely on the user of the function to insert a slash
> to denote a directory...
(setq file "") ⇒ ""
(file-exists-p file) ⇒ t ;; this is funny to me, but I guess both
;; directory and file are files...
(file-exists-p "/") ⇒ t ;; aha, directory is file too...
Then:
(expand-file-name file) ⇒ "/home/data1/protected/tmp" ;; aha, this one is
;; directory,
;; that is why
;; empty string
;; is considered
;; file.
(file-name-as-directory "") ⇒ "./" ;; now it makes more sense
and now we get it as directory with a slash:
(file-name-as-directory (expand-file-name "")) ⇒ "/home/data1/protected/tmp/"
(defun directory (file)
(when (and (stringp file) (file-exists-p file))
(file-name-as-directory (expand-file-name file))))
(directory "") ⇒ "/home/data1/protected/tmp/" ;; because that is my current
directory
(directory "/home") ⇒ "/home/"
If directory does not exist, return NIL:
(directory "/home-is-not-here") ⇒ nil
--
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/
- Re: Emacs Modular Configuration: the preferable way., (continued)
Re: Emacs Modular Configuration: the preferable way., Arthur Miller, 2021/06/21
Re: Emacs Modular Configuration: the preferable way., Arthur Miller, 2021/06/21
Re: Emacs Modular Configuration: the preferable way., Emanuel Berg, 2021/06/21
Re: Emacs Modular Configuration: the preferable way.,
Jean Louis <=
Re: Emacs Modular Configuration: the preferable way., Arthur Miller, 2021/06/22
Re: Emacs Modular Configuration: the preferable way., Emanuel Berg, 2021/06/26
Re: Emacs Modular Configuration: the preferable way., Eli Zaretskii, 2021/06/21
- Re: Emacs Modular Configuration: the preferable way., Philip Kaludercic, 2021/06/21
- Re: Emacs Modular Configuration: the preferable way., Eli Zaretskii, 2021/06/21
- RE: [External] : Re: Emacs Modular Configuration: the preferable way., Drew Adams, 2021/06/21
- Re: [External] : Re: Emacs Modular Configuration: the preferable way., Emanuel Berg, 2021/06/21
- Re: [External] : Re: Emacs Modular Configuration: the preferable way., Eli Zaretskii, 2021/06/21
- FW: [External] : Re: Emacs Modular Configuration: the preferable way., Drew Adams, 2021/06/21
- Re: FW: [External] : Re: Emacs Modular Configuration: the preferable way., Emanuel Berg, 2021/06/25