Arc Forumnew | comments | leaders | submitlogin
Can't paste Arc code out of emacs
2 points by lojic 5887 days ago | 15 comments
This is really strange, and I'm wondering if anyone else is experiencing this problem with Arc code in emacs.

I can't paste Arc code into a window other than the emacs window the code is in. As far as I can tell, this is only happening with buffers containing Arc code. I've tried switching the mode to text or lisp, but that doesn't help.

I can paste fine into the same emacs window, and if I copy code from the Arc file to a new buffer, I can then copy with the mouse and paste elsewhere as normal.

Has anyone else experienced this? I'm running emacs 23 from source on Ubuntu 7.10.

I thought the problem might be with arc.el, but I've turned that off and have the same problem. I can copy/paste ac.scm, but not news.arc for example.

Could this be a file encoding issue?



1 point by lojic 5887 days ago | link

I think I found the problem. It looks like the auto-coding-alist is the culprit:

  (("\\.\\(arc\\|zip\\|lzh\\|lha\\|zoo\\|[jew]ar\\|xpi\\|exe\\|rar\\|ARC\\|ZIP\\|LZH\\|LHA\\|ZOO\\|[JEW]AR\\|XPI\\|EXE\\|RAR\\)\\'" . no-conversion)
   ("\\.\\(sx[dmicw]\\|odt\\|tar\\|tgz\\)\\'" . no-conversion)
   ("\\.\\(gz\\|Z\\|bz\\|bz2\\|gpg\\)\\'" . no-conversion)
   ("\\.\\(jpe?g\\|png\\|gif\\|tiff?\\|p[bpgn]m\\)\\'" . no-conversion)
   ("\\.pdf\\'" . no-conversion)
   ("/#[^/]+#\\'" . emacs-mule))
Documentation:

Alist of filename patterns vs corresponding coding systems. Each element looks like (REGEXP . CODING-SYSTEM). A file whose name matches REGEXP is decoded by CODING-SYSTEM on reading.

The settings in this alist take priority over `coding:' tags in the file (see the function `set-auto-coding') and the contents of `file-coding-system-alist'.

-----

3 points by nex3 5887 days ago | link

Okay, here's a new solution:

  (dolist (coding auto-coding-alist)
    (when (and (string-match "[Aa][Rr][Cc]\\\\|" (car coding))
               (eq (cdr coding) 'no-conversion))
      (setcar coding (replace-match "" nil nil (car coding)))))
I'll replace the fix in arc.el.

-----

1 point by lojic 5887 days ago | link

Cool. And thanks for the great elisp examples - I'm just learning elisp (and Lisp in general), so every bit helps.

-----

1 point by nex3 5887 days ago | link

No problem :-).

In my experience, the most important thing to remember when learning elisp is "C-h f", followed by "C-h i m elisp RET".

-----

1 point by nex3 5887 days ago | link

Are you sure this is it? Because my solution (http://arclanguage.org/item?id=4536) works for me, and doesn't touch auto-coding-alist.

Edit: Oh, wait, maybe it's not working. Gah.

-----

1 point by lojic 5887 days ago | link

Yes, I'm sure :) I did:

  C-h v auto-code-alist
and clicked on the customize link, then removed arc, and everything works great.

If only pg used emacs :)

-----

1 point by lojic 5887 days ago | link

Just got stranger. It appears to have something to do with the file name. I copied arc.arc to bja.scm and I could copy/paste. I copied bja.scm to bja.arc and couldn't copy/paste.

So changing the emacs mode has no effect on an existing buffer, but changing the file name does. I guess there's something about a .arc extension that turns off copy/paste from emacs.

edit: another datapoint - everything works fine when running emacs w/o X via: emacs -nw arc.arc

While experimenting, I received the following error after entering the following from the command line:

emacs bja.arc

"File mode specification error: (error "Autoloading failed to define function archive-mode")

-----

1 point by nex3 5887 days ago | link

I'm on Emacs 23.0.60.2, and I haven't seen anything like this. Could you be a little more specific, so I can run tests? Are you saying that you have text in a .arc buffer, you kill it, and you can't yank it into other buffers?

-----

1 point by lojic 5887 days ago | link

No, I'm simply selecting text with the mouse in an Arc buffer and trying to paste with the middle-button in a non-emacs window such as this text area.

I've narrowed the problem down to the filename extension. Here's the test:

  brian@airstream:~/temp$ cat > temp.arc
  hello, world
  <ctrl>-d
  emacs temp.arc
Then select some text with the mouse and try and paste in a non-emacs window using the middle button. I can do this with everything but files ending in .arc !

  brian@airstream:~/temp$ emacs --version
  GNU Emacs 23.0.60.2
I just killed my .emacs file as a test and I get the same results, so you should be able to duplicate that if you're on Linux.

With no .emacs file, I see the following message when loading temp.arc:

File mode specification error: (error "Buffer format not recognized")

I expect that's related. Maybe we can get pg to use another extension like .arclisp :)

-----

2 points by nex3 5887 days ago | link

Okay, now I'm seeing the problem. I'll poke around with it.

Edit:

Looks like you're right: .arc is recognized as an archive-mode file. This snippet should fix it:

  (let* ((mode (rassoc 'archive-mode auto-mode-alist))
         (str (car mode)))
    (string-match "[Aa][Rr][Cc]\\\\|" str)
    (setcar mode (replace-match "" nil nil str)))
I've added this to arc.el.

-----

1 point by lojic 5887 days ago | link

So it's not sufficient to add the new arc.el, you have to remove the existing association also? I would think that once a match is found in the auto-mode-alist, it wouldn't consider the other entries.

BTW I started a thread on gnu.emacs.help, but if the above fixes it, it's moot.

http://groups.google.com/group/gnu.emacs.help/browse_frm/thr...

-----

1 point by nex3 5887 days ago | link

Well, I added the above code to arc.el, so it should automatically disassociate *.arc with archive-mode.

-----

1 point by nex3 5887 days ago | link

Okay, this didn't actually solve it. This should, though: http://arclanguage.org/item?id=4548.

-----

1 point by lojic 5887 days ago | link

Yay, I'm not crazy! :)

-----

1 point by drcode 5887 days ago | link

i've noticed the same problem.

-----