From mboxrd@z Thu Jan 1 00:00:00 1970 From: Brent Goodrick Subject: Bug: Prevent fill-paragraph from breaking inside Org mode links [9.1.9 (release_9.1.9-580-g39837b @ /home/drunkard/emacs_lisp_imported/org-mode/org-mode/lisp/)] Date: Sun, 8 Apr 2018 08:51:31 -0700 Message-ID: <23242.14979.666606.8006@bgnetgear2.ddns.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:43294) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f5CbX-0007rv-Vi for emacs-orgmode@gnu.org; Sun, 08 Apr 2018 11:51:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f5CbT-00075R-CE for emacs-orgmode@gnu.org; Sun, 08 Apr 2018 11:51:44 -0400 Received: from mail-pl0-x236.google.com ([2607:f8b0:400e:c01::236]:41983) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f5CbT-00073v-1E for emacs-orgmode@gnu.org; Sun, 08 Apr 2018 11:51:39 -0400 Received: by mail-pl0-x236.google.com with SMTP id bj1-v6so3627407plb.8 for ; Sun, 08 Apr 2018 08:51:38 -0700 (PDT) Received: from wilddog.thisisbogus.com (76-14-232-250.or.wavecable.com. [76.14.232.250]) by smtp.gmail.com with ESMTPSA id t25sm25836901pfh.184.2018.04.08.08.51.35 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 08 Apr 2018 08:51:35 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org ------------------------------------------------------------------------ This is not a new bug. It has been there for a long time, but I am only just now getting around to reporting it. I am also proposing a fix below. How to reproduce: Open up a Org mode file and add the following item to it: 1. Now is the time for all good men and women to [[id:269cedb3-9a50-4de9-9696-f8297c18a75a][come to the aid of their KEG PARTY]] Ensure you have run `org-toggle-link-display' to show the "descriptive display" of links, not the literal display that might show up in your email view of the above line (e.g., the "[id:269cedb3-9a50-4de9-9696-f8297c18a75a]" part will not show up in the "descriptive" link display mode). Move point to the "a" in "aid", and type C-x f (set-fill-column) to set the fill column to 62. Place point anywhere inside the above line after the "1. " (e.g. at the "g" in "good"). Type M-x org-fill-paragraph. The result is 1. Now is the time for all good men and women to [[id:269cedb3-9a50-4de9-9696-f8297c18a75a][come to the aid of their KEG PARTY]] Not only is the above result visually jarring (see https://i.imgur.com/HnY70le.png for an annotated screenshot) when in "descriptive link" display mode, it also breaks `org-return', as follows: Move the point to the "g" in "good" in the line above. Type M-x org-next-link to got to that first link, then type M-x org-return. The result is an insertion of a newline, resulting in: 1. Now is the time for all good men and women to [[id:269cedb3-9a50-4de9-9696-f8297c18a75a][come to the aid of their KEG PARTY]] when I expect it to navigate to the heading upon which is associated with "id:269cedb3-9a50-4de9-9696-f8297c18a75a". Here is my proposed fix: First, it may be a separate "bug" that org-return cannot recognize the multi-line Org link. I don't know one way or the other for that, but instead I am arguing that org mode's fill paragraph function should never break the line right in the middle of the link. Instead the whole link should be treated as a word. To illustrate the fix, I have appended my own function to `fill-nobreak-predicate' to prevent the breakages, but taking hints from `org-setup-filling' which does similar things for other areas of Org mode buffers: (defun bg-org-fill-paragraph-with-link-nobreak-p () "Do not allow `fill-paragraph' to break inside the middle of Org mode links." (and (assq :link (org-context)) t)) (defun bg-org-fill-paragraph-config () "Configure `fill-paragraph' for Org mode." ;; Append a function to fill-nobreak-predicate similarly to how org-mode does ;; inside `org-setup-filling': (when (boundp 'fill-nobreak-predicate) (setq-local fill-nobreak-predicate (org-uniquify (append fill-nobreak-predicate '(bg-org-fill-paragraph-with-link-nobreak-p)))))) And then run bg-org-fill-paragraph-config from my `org-mode-hook' function. The fix I propose is to change `org-setup-filling' to do the above. Thanks, Brent Emacs : GNU Emacs 25.2.2 (x86_64-pc-linux-gnu, GTK+ Version 3.22.21) of 2017-09-22, modified by Debian Package: Org mode version 9.1.9 (release_9.1.9-580-g39837b @ /home/drunkard/emacs_lisp_imported/org-mode/org-mode/lisp/) current state: ============== (setq org-id-locations-file "/home/drunkard/Plans/Home/.org-id-locations" org-tab-first-hook '(org-babel-hide-result-toggle-maybe org-babel-header-arg-expand) outline-minor-mode-hook '(wikipedia-outline-magic-keys (lambda nil (require (quote outline-magic)))) org-clock-persist-file "/home/drunkard/Plans/Home/org-clock-save.el" org-speed-command-hook '(org-speed-command-activate org-babel-speed-command-activate) org-occur-hook '(org-first-headline-recenter) org-metaup-hook '(org-babel-load-in-session-maybe) org-html-format-drawer-function #[514 "\207" [] 3 "\n\n(fn NAME CONTENTS)"] org-latex-format-inlinetask-function 'org-latex-format-inlinetask-default-function org-confirm-shell-link-function 'yes-or-no-p org-id-link-to-org-use-id t org-ascii-format-inlinetask-function 'org-ascii-format-inlinetask-default org-clock-idle-time 10 org-startup-folded nil org-file-apps '((auto-mode . emacs) ("\\.mm\\'" . default) ("\\.x?html?\\'" browse-url-of-file (expand-file-name file)) ("\\.pdf\\'" . default)) org-tab-before-tab-emulation-hook '(org-tempo-complete-tag) org-export-with-sub-superscripts nil org-return-follows-link t org-latex-format-headline-function 'org-latex-format-headline-default-function org-default-notes-file "/home/drunkard/Plans/Home/notes.org" org-after-todo-state-change-hook '(org-clock-out-if-current) org-latex-format-drawer-function #[514 "\207" [] 3 "\n\n(fn _ CONTENTS)"] org-odt-format-headline-function 'org-odt-format-headline-default-function org-src-mode-hook '(org-src-babel-configure-edit-buffer org-src-mode-configure-edit-buffer) org-agenda-before-write-hook '(org-agenda-add-entry-text) org-babel-pre-tangle-hook '(save-buffer) org-html-head-include-default-style nil org-mode-hook '(org-tempo-setup org-clock-load bg-org-mode-hook #[0 "\300\301\302\303\304$\207" [add-hook change-major-mode-hook org-show-all append local] 5] #[0 "\300\301\302\303\304$\207" [add-hook change-major-mode-hook org-babel-show-result-all append local] 5] org-babel-result-hide-spec org-babel-hide-all-hashes) org-refile-targets '((nil :maxlevel . 9) (org-agenda-files :maxlevel . 9)) org-bibtex-headline-format-function #[257 "\300\236A\207" [:title] 3 "\n\n(fn ENTRY)"] org-archive-hook '(org-attach-archive-delete-maybe) org-ascii-format-drawer-function #[771 "\207" [] 4 "\n\n(fn NAME CONTENTS WIDTH)"] org-odt-format-inlinetask-function 'org-odt-format-inlinetask-default-function org-clock-persist t org-refile-use-outline-path 'file org-directory "/home/drunkard/Plans/Home" org-cycle-hook '(org-cycle-hide-archived-subtrees org-cycle-show-empty-lines org-optimize-window-after-visibility-change) org-plantuml-jar-path "/home/drunkard/plantuml/plantuml.jar" org-edit-src-auto-save-idle-delay 5 org-todo-keywords '((sequence "TODO(t)" "|" "DONE(d)" "SHELVED(s)" "DELEGATED(e)")) org-babel-tangle-lang-exts '(("python" . "py") ("emacs-lisp" . "el") ("elisp" . "el")) org-confirm-elisp-link-function 'bg-org-confirm-elisp-link org-html-htmlize-output-type 'css org-metadown-hook '(org-babel-pop-to-session-maybe) outline-mode-hook '((lambda nil (require (quote outline-magic)))) org-odt-format-drawer-function #[514 "\207" [] 3 "\n\n(fn NAME CONTENTS)"] org-babel-after-execute-hook '(bg-org-babel-after-execute-hook) org-html-format-headline-function 'org-html-format-headline-default-function org-link-parameters '(("rmail" :follow org-rmail-open :store org-rmail-store-link) ("mhe" :follow org-mhe-open :store org-mhe-store-link) ("irc" :follow org-irc-visit :store org-irc-store-link :export org-irc-export) ("info" :follow org-info-open :export org-info-export :store org-info-store-link) ("gnus" :follow org-gnus-open :store org-gnus-store-link) ("docview" :follow org-docview-open :export org-docview-export :store org-docview-store-link) ("bibtex" :follow org-bibtex-open :store org-bibtex-store-link) ("bbdb" :follow org-bbdb-open :export org-bbdb-export :complete org-bbdb-complete-link :store org-bbdb-store-link) ("w3m" :store org-w3m-store-link) ("id" :follow org-id-open) ("file+sys") ("file+emacs") ("doi" :follow org--open-doi-link) ("elisp" :follow org--open-elisp-link) ("file" :complete org-file-complete-link) ("ftp" :follow (lambda (path) (browse-url (concat "ftp:" path)))) ("help" :follow org--open-help-link) ("http" :follow (lambda (path) (browse-url (concat "http:" path)))) ("https" :follow (lambda (path) (browse-url (concat "https:" path)))) ("mailto" :follow (lambda (path) (browse-url (concat "mailto:" path)))) ("news" :follow (lambda (path) (browse-url (concat "news:" path)))) ("shell" :follow org--open-shell-link)) org-babel-load-languages '((emacs-lisp . t) (python . t) (shell . t) (sqlite . t) (dot . t) (plantuml . t)) org-clock-in-hook '(bg-org-clock-in-hook) org-html-format-inlinetask-function 'org-html-format-inlinetask-default-function org-agenda-files "/home/drunkard/Plans/Home/org-agenda-files-list-file.txt" org-clock-out-hook '(org-clock-remove-empty-clock-drawer) org-confirm-babel-evaluate 'bg-org-confirm-babel-evaluate org-export-headline-levels 100 org-publish-project-alist '(("my-emacs-lisp-org" :base-directory "~/emacs_lisp/" :publishing-directory "~/public_html/emacs_lisp" :recursive t :table-of-contents t :base-extension "org" :publishing-function org-html-publish-to-html :style-include-default nil :section-numbers t :with-sub-superscript nil :html-head "" :author-info nil :creator-info nil) ("my-emacs-lisp-extra" :base-directory "~/emacs_lisp/" :publishing-directory "~/public_html/emacs_lisp" :base-extension "css\\|pdf\\|png\\|jpg\\|gif" :publishing-function org-publish-attachment :recursive t :author nil) ("my-emacs-lisp" :components ("my-emacs-lisp-org" "my-emacs-lisp-extra"))) )