{"id":7848,"date":"2019-02-17T14:07:03","date_gmt":"2019-02-17T19:07:03","guid":{"rendered":"https:\/\/irreal.org\/blog\/?p=7848"},"modified":"2019-02-17T14:07:03","modified_gmt":"2019-02-17T19:07:03","slug":"copying-the-whole-buffer","status":"publish","type":"post","link":"https:\/\/irreal.org\/blog\/?p=7848","title":{"rendered":"Copying the Whole Buffer"},"content":{"rendered":"<p>Tim Bray tweeted a nice bit of elisp to copy the current buffer to the kill ring:<\/p>\n<blockquote class=\"twitter-tweet\" data-lang=\"en\">\n<p lang=\"en\" dir=\"ltr\">For mac\/emacs people:<br \/>\n&lt;&lt;&lt;&lt;<br \/>\n(defun copy-whole-buffer () &#8220;Command A stupid&#8221; (interactive)<br \/>\n(save-excursion<br \/>\n(mark-whole-buffer)<br \/>\n(copy-region-as-kill 1 (buffer-size))))<br \/>\n(global-set-key [(meta a)] &#8216;copy-whole-buffer)<br \/>\n&lt;&lt;&lt;&lt;<br \/>\n[Don&#8217;t know why I didn\u2019t do this years ago\u2026]<\/p>\n<p>\u2014 Tim Bray (@timbray) <a href=\"https:\/\/twitter.com\/timbray\/status\/1096557429477695488?ref_src=twsrc%5Etfw\">February 15, 2019<\/a><\/p><\/blockquote>\n<p><script async=\"\" src=\"https:\/\/platform.twitter.com\/widgets.js\" charset=\"utf-8\"><\/script><\/p>\n<p>The normal method\u2014or at least <i>my<\/i> normal method\u2014is to mark the buffer with <kbd>Ctrl<\/kbd>+<kbd>x<\/kbd> <kbd>h<\/kbd> and then copy it to the kill ring with <kbd>Meta<\/kbd>+<kbd>w<\/kbd>. That\u2019s pretty simple and it\u2019s burned into my muscle memory but I do that operation a lot so it probably makes sense to get it bound to a single key sequence. In any event, if you often find yourself wanting to capture the buffer so you can paste it somewhere else, Bray\u2019s code is just what you need.<\/p>\n<p>My only quibble is binding it to <kbd>Meta<\/kbd>+<kbd>a<\/kbd>. By default, that\u2019s bound to either <code>backward-sentence<\/code> or <code>org-backward-sentence<\/code>, which I use all the time. If you use or think you might use the go to beginning and end of sentence functions, you should probably bind Bray\u2019s code to something else.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Tim Bray tweeted a nice bit of elisp to copy the current buffer to the kill ring: For mac\/emacs people: &lt;&lt;&lt;&lt; (defun copy-whole-buffer () &#8220;Command A stupid&#8221; (interactive) (save-excursion (mark-whole-buffer) (copy-region-as-kill 1 (buffer-size)))) (global-set-key [(meta a)] &#8216;copy-whole-buffer) &lt;&lt;&lt;&lt; [Don&#8217;t know &hellip; <a href=\"https:\/\/irreal.org\/blog\/?p=7848\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[18],"class_list":["post-7848","post","type-post","status-publish","format-standard","hentry","category-general","tag-emacs"],"_links":{"self":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/7848","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7848"}],"version-history":[{"count":1,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/7848\/revisions"}],"predecessor-version":[{"id":7849,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/7848\/revisions\/7849"}],"wp:attachment":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7848"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7848"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7848"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}