[ESS] clash between setwd macro and skeleton-pair

Vitalie Spinu spinuvit.list at gmail.com
Wed Aug 10 23:02:19 CEST 2011


Ah, sorry,

I see now what you mean by running your macro.

Here is the function which does it the way you like:


(defun my-ess-insert-setwd ()
  (interactive)
  (let ((this-file (buffer-file-name)))
    (when this-file
      (insert (format "setwd(\"%s\")"  (file-name-directory this-file))))
    ))

Cheers,
Vitalie.

On Wed, Aug 10, 2011 at 12:26 AM, baptiste auguie
<baptiste.auguie at googlemail.com> wrote:
> Thanks Vitalie, this is a very useful tip. I would still like to have
> the setwd() directive visually present in my script, so that when I
> run the buffer it will always read/save files in the same directory,
> say.
>
> All the best,
>
> baptiste
>
> On 10 August 2011 01:48, Vitalie Spinu <spinuvit.list at gmail.com> wrote:
>> baptiste auguie <baptiste.auguie at googlemail.com> writes:
>>
>>
>> Hi,
>>
>> You can use 'ess-use-this-dir' instead of your macro. If I understood
>> correctly, it does exactly what you want.
>>
>> Also note that \C-c\C-s is bound by default to ess-switch-process which is
>> also very useful if you are  working with multiple processes.
>>
>> Vitalie.
>>
>>
>>> Dear emacs gurus,
>>>
>>> Thanks to previous tips from this list I've been the .emacs file shown
>>> below for a while, and I'd like to get rid off an annoying clash in
>>> it. The first option I have set is to autocomplete matching
>>> parentheses etc. The last option defines a shortcut for R to setwd(
>>> ... where the current file actually lives ....), which I find very
>>> useful. Somehow this last macro is incompatible with the first,
>>> typically resulting in
>>>
>>> setwd("")/Users/auguieba/Documents/")"
>>>
>>> Best regards,
>>>
>>> baptiste
>>>
>>> My .emacs file contains:
>>>
>>> (setq ess-eval-visibly-p nil)
>>>    (setq skeleton-pair t)
>>>    (global-set-key (kbd "(") 'skeleton-pair-insert-maybe)
>>>    (global-set-key (kbd "[") 'skeleton-pair-insert-maybe)
>>>    (global-set-key (kbd "{") 'skeleton-pair-insert-maybe)
>>>    (global-set-key (kbd "\"") 'skeleton-pair-insert-maybe)
>>>    (global-set-key (kbd "\'") 'skeleton-pair-insert-maybe)
>>>    (global-set-key (kbd "\`") 'skeleton-pair-insert-maybe)
>>>    (global-set-key (kbd "<") 'skeleton-pair-insert-maybe)
>>>
>>> (windmove-default-keybindings)
>>>
>>> (fset 'my-setwd-macro
>>>       [?\C-  ?\C-u ?\M-| ?p ?w ?d return ?\C-p ?s ?e ?t ?w ?d ?\( ?\" ?\C-e ?\"
>>>            ?\)])
>>>
>>> (add-hook
>>>  'ess-mode-hook
>>>   '(lambda()
>>>      (define-key ess-mode-map "\C-c\C-s" 'my-setwd-macro)))
>>>
>>> ______________________________________________
>>> ESS-help at r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/ess-help
>>
>



More information about the ESS-help mailing list