Hacker News new | ask | show | jobs
by dctoedt 3 days ago
An emacs routine to convert a region of org-mode formatting to Markdown formatting and put into the clipboard:

  ;; Written by Claude 2026-06-06 
  (defun my/org-to-markdown-clipboard ()
    "Export org region (or buffer) to Markdown and copy to clipboard.
  With no active region, exports the whole buffer."
    (interactive)
    (require 'ox-md)
    (let* ((text (if (use-region-p)
                     (buffer-substring-no-properties (region-beginning) (region-end))
                   (buffer-substring-no-properties (point-min) (point-max))))
           (md (org-export-string-as text 'md t '(:with-toc nil
                                                  :with-author nil
                                                  :with-date nil
                                                  :with-title nil))))
      (kill-new md)
      (message "Markdown copied (%d chars)" (length md))))
  
  (with-eval-after-load 'org
    (define-key org-mode-map (kbd "C-c m") #'my/org-to-markdown-clipboard))