Loading ...
Sorry, an error occurred while loading the content.

2382find-buffer docsbugs? and copy-filename function encl

Expand Messages
  • Tom Hundt
    Jul 20 6:09 PM
    • 0 Attachment

      I wanted to write a function to copy the path and filename of the currently-open file.  (In termcap or console mode, I could copy at least the visible part of the filename to the clipboard by selecting the text in the modeline.  But, I couldn't figure out how to do it in the GUI version.)

      I came up with this hack (below), which works.  (BTW I'm using ME 2006/09/09.)

      ; copy-filename: copy file name to clipboard
      ; (copies entire path + filename)
      define-macro copy-filename
          set-variable #l0 $buffer-fname
          1 find-buffer "*copy-filename*"
          insert-string #l0
          kill-region  ; copies to clipboard
          delete-buffer "*copy-filename*"

      In writing this, I had some trouble with find-buffer.
      I wanted the switch to the buffer and the paste/kill actions not to be seen by the user.
      A "hidden" buffer sounded like just the ticket.
      The manpage says if the param to find-buffer is negative, the buffer is "hidden". 
      And then it also says if bit 0x8 is set, the buffer is hidden.
      So there might be a docsbug here.
      Also, when I tried both of these things (individually and together) they caused my code not to work. Values -1, -8, -9 caused errors outright, and 9 caused it not to switch buffers.

      And it turns out the buffer switch isn't visible after all, so leaving it as "1" seems to be okay.



      Thomas Hundt <tom@...> +1-415-867-6698

    • Show all 4 messages in this topic