From: "Óscar Fuentes" <ofv@wanadoo.es>
To: help-gnu-emacs@gnu.org
Subject: Re: Refer to the directory of the currently being loaded elisp script from within the Emacs lisp file itself.
Date: Fri, 11 Jun 2021 03:14:42 +0200 [thread overview]
Message-ID: <87y2bh6w3h.fsf@telefonica.net> (raw)
In-Reply-To: CAGP6PO+SHrLr+5tiFna4u8B4s6NbJ28YrZ35M+JCDOguEkH93w@mail.gmail.com
Hongyi Zhao <hongyi.zhao@gmail.com> writes:
> On Thu, Jun 10, 2021 at 11:40 PM Óscar Fuentes <ofv@wanadoo.es> wrote:
>>
>> Hongyi Zhao <hongyi.zhao@gmail.com> writes:
>>
>> >> BTW, the correct method for concatenating a directory and a file name is
>> >>
>> >> (load-file
>> >> (concat
>> >> (file-name-as-directory (file-name-directory load-file-name))
>> >> "auth.el.gpg"))
>> >
>> > I tried you above code, it still doesn't work with the following info:
>> >
>> > file-name-as-directory: Wrong type argument: stringp, nil [2 times]
>> > Mark set
>>
>> load-file-name is defined while the file is being loaded, after that it
>> is nil. So if you tried with `C-x C-e' or some other interactive command
>> it wont work.
>>
>> Once the code above is in the correct file, save it, start Emacs and
>> report back what happens.
>
> See my current usage on
> <https://github.com/hongyi-zhao/screen2latex.el/blob/bd820184a29158c14de1afaf564f9e2898dd88ac/screen2latex.el#L45>
> according to the instructions here.
>
> After I start Emacs and tried with `M-x screenlatex RET', I will see
> the following info in *Messages* buffer:
>
> expand-file-name: Wrong type argument: stringp, nil
As explained previously, load-file-name is only defined when the file is
being loaded, otherwise it is nil.
You can put the directory name on a variable at load time and use that
variable on your command:
(setq my-directory (file-name-directory load-file-name)
(defun screen2latex ()
...
(load-file (expand-file-name "auth.el.gpg" my-directory))
next prev parent reply other threads:[~2021-06-11 1:14 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-10 15:02 Refer to the directory of the currently being loaded elisp script from within the Emacs lisp file itself Hongyi Zhao
2021-06-10 15:24 ` Óscar Fuentes
2021-06-10 15:31 ` Hongyi Zhao
2021-06-10 15:40 ` Óscar Fuentes
2021-06-10 23:55 ` Hongyi Zhao
2021-06-11 1:14 ` Óscar Fuentes [this message]
2021-06-11 3:47 ` Hongyi Zhao
2021-06-11 13:49 ` Óscar Fuentes
2021-06-11 14:26 ` Hongyi Zhao
2021-06-10 15:31 ` Eli Zaretskii
2021-06-10 15:38 ` Hongyi Zhao
2021-06-10 15:42 ` Óscar Fuentes
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87y2bh6w3h.fsf@telefonica.net \
--to=ofv@wanadoo.es \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).