Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
patch for org-9.3 release to fit in emacs-mac
diff --git a/lisp/org-compat.el b/lisp/org-compat.el
index 4446a169d..2d1f2ff92 100644
--- a/lisp/org-compat.el
+++ b/lisp/org-compat.el
@@ -646,7 +646,12 @@ use of this function is for the stuck project list."
(gui-get-selection value 'STRING)
(gui-get-selection value 'TEXT)))))
((and (eq window-system 'w32) (fboundp 'w32-get-clipboard-data))
- (w32-get-clipboard-data))))
+ (w32-get-clipboard-data))
+ ((and (eq window-system 'mac)
+ (fboundp 'gui-get-selection)) ;Silence byte-compiler.
+ (org-no-properties
+ (ignore-errors
+ (gui-get-selection 'CLIPBOARD 'NSStringPboardType))))))
;; `set-transient-map' is only in Emacs >= 24.4
(defalias 'org-set-transient-map
diff --git a/lisp/org-protocol.el b/lisp/org-protocol.el
index 44c6abbd9..545427737 100644
--- a/lisp/org-protocol.el
+++ b/lisp/org-protocol.el
@@ -583,7 +583,7 @@ The location for a browser's bookmark should look like this:
;;; Core functions:
-(defun org-protocol-check-filename-for-protocol (fname restoffiles _client)
+(defun org-protocol-check-filename-for-protocol (fname restoffiles client)
"Check if `org-protocol-the-protocol' and a valid protocol are used in FNAME.
Sub-protocols are registered in `org-protocol-protocol-alist' and
`org-protocol-protocol-alist-default'. This is how the matching is done:
@@ -624,7 +624,10 @@ CLIENT is ignored."
(split (split-string fname proto))
(result (if greedy restoffiles (cadr split)))
(new-style (string= (match-string 1 fname) "?")))
- (when (plist-get (cdr prolist) :kill-client)
+ ;; Emacs Mac port directly handles `org-protocol'
+ ;; URLs without the help of external commands or
+ ;; apps. In this case, `client' is set to nil.
+ (when (and client (plist-get (cdr prolist) :kill-client))
(message "Greedy org-protocol handler. Killing client.")
(when (fboundp func)
diff --git a/lisp/org.el b/lisp/org.el
index 67c5d1b2f..887be55a7 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -16217,6 +16217,10 @@ fragments in the buffer."
(org--latex-preview-region beg end)
(message "Creating LaTeX previews in section... done.")))))
+(declare-function mac-possibly-use-high-resolution-monitors-p
+ "term/mac-win" ())
+(declare-function mac-high-resolution-image-file-name
+ "term/mac-win" (filename &optional scale))
(defun org-format-latex
(prefix &optional beg end dir overlays msg forbuffer processing-type)
"Replace LaTeX fragments with links to an image.
@@ -16295,6 +16299,11 @@ Some of the options can be changed using the variable
(absprefix (expand-file-name prefix dir))
(linkfile (format "%s_%s.%s" prefix hash imagetype))
(movefile (format "%s_%s.%s" absprefix hash imagetype))
+ (move2xfile
+ (and (fboundp 'mac-high-resolution-image-file-name)
+ (not (string= imagetype "svg"))
+ (mac-possibly-use-high-resolution-monitors-p)
+ (mac-high-resolution-image-file-name movefile)))
(sep (and block-type "\n\n"))
(link (concat sep "[[file:" linkfile "]]" sep))
@@ -16307,7 +16316,12 @@ Some of the options can be changed using the variable
(let ((todir (file-name-directory absprefix)))
(unless (file-directory-p todir)
(make-directory todir t))))
- (unless (file-exists-p movefile)
+ (unless (and (file-exists-p movefile)
+ (or (null move2xfile)
+ (file-exists-p move2xfile)))
+ (if move2xfile
+ (setq options
+ (plist-put options :to2xfile move2xfile)))
value movefile options forbuffer processing-type))
(if overlays
@@ -16488,6 +16502,7 @@ a HTML file."
(bg (or (plist-get options (if buffer :background :html-background))
+ (to2xfile (plist-get options :to2xfile))
(log-buf (get-buffer-create "*Org Preview LaTeX Output*"))
(resize-mini-windows nil)) ;Fix Emacs flicker when creating image.
(dolist (program programs)
@@ -16519,8 +16534,19 @@ a HTML file."
image-input-file image-converter image-output-type err-msg log-buf
`((?D . ,(shell-quote-argument (format "%s" dpi)))
- (?S . ,(shell-quote-argument (format "%s" (/ dpi 140.0))))))))
+ (?S . ,(shell-quote-argument (format "%s" (/ dpi 140.0)))))))
+ (image-output-2x-file
+ (and
+ to2xfile
+ (org-compile-file
+ image-input-file image-converter image-output-type err-msg log-buf
+ `((?F . ,(shell-quote-argument fg))
+ (?B . ,(shell-quote-argument bg))
+ (?D . ,(shell-quote-argument (format "%s" (* dpi 2))))
+ (?S . ,(shell-quote-argument (format "%s" (/ dpi 140.0)))))))))
(copy-file image-output-file tofile 'replace)
+ (if to2xfile
+ (copy-file image-output-2x-file to2xfile 'replace))
(dolist (e post-clean)
(when (file-exists-p (concat texfilebase e))
(delete-file (concat texfilebase e))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment