bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#63648: 29.0.90; project.el: with switch-use-entire-map, switch-proje


From: Eli Zaretskii
Subject: bug#63648: 29.0.90; project.el: with switch-use-entire-map, switch-project errors on non-project commands
Date: Fri, 02 Jun 2023 09:32:58 +0300

> Cc: Spencer Baugh <sbaugh@janestreet.com>, 63648@debbugs.gnu.org
> From: Juri Linkov <juri@linkov.net>
> Date: Thu, 01 Jun 2023 19:05:07 +0300
> 
> And indeed with the following patch replacing the current definition of
> 'project-switch-project' with just:
> 
>   (defun project-switch-project (dir)
>     (interactive (list (funcall project-prompter)))
>     (setq next-default-directory dir))
> 
> 'C-x p p (select project ...) RET M-& pwd RET' confirms that
> the command runs in the selected project directory.
> Whereas the original buffer keeps its previous buffer-local value
> of 'default-directory'.
> 
> diff --git a/src/buffer.c b/src/buffer.c
> index 0c46b201586..ca81db21894 100644
> --- a/src/buffer.c
> +++ b/src/buffer.c
> @@ -5360,6 +5360,10 @@ syms_of_buffer (void)
>  these names start with `/' or `~' and end with `/'.
>  To interactively change the default directory, use command `cd'. */);
>  
> +  DEFVAR_LISP ("next-default-directory", Vnext_default_directory,
> +            doc: /* Default directory for the next command.  */);
> +  Vnext_default_directory = Qnil;
> +
>    DEFVAR_PER_BUFFER ("auto-fill-function", &BVAR (current_buffer, 
> auto_fill_function),
>                    Qnil,
>                    doc: /* Function called (if non-nil) to perform auto-fill.
> diff --git a/src/keyboard.c b/src/keyboard.c
> index 14c55666768..dfe939750c9 100644
> --- a/src/keyboard.c
> +++ b/src/keyboard.c
> @@ -1500,7 +1500,19 @@ command_loop_1 (void)
>           update_redisplay_ticks (0, NULL);
>           display_working_on_window_p = false;
>  
> +            Lisp_Object next_dir = Vnext_default_directory;
> +            specpdl_ref count = SPECPDL_INDEX ();
> +            if (!NILP (next_dir))
> +              specbind (Qdefault_directory, next_dir);
> +
>              call1 (Qcommand_execute, Vthis_command);
> +
> +            if (!NILP (next_dir))
> +              {
> +                unbind_to (count, Qnil);
> +                Vnext_default_directory = Qnil;
> +              }
> +
>           display_working_on_window_p = false;
>  
>  #ifdef HAVE_WINDOW_SYSTEM

What will this do when a command is invoked via call-interactively?





reply via email to

[Prev in Thread] Current Thread [Next in Thread]