-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
outline-{promote, demote} does not seem to work well. #63
Comments
Hi, Your English is actually quite good. :)
@thblt What do you think? Thanks. |
Thank you for your polite advice! I will look up Thanks, |
Owing to @alphapapa, ;; with AUCTeX, see
;; https://www.gnu.org/software/auctex/
(add-hook 'LaTeX-mode-hook #'(lambda ()
(outshine-mode 1)
(setq outline-level #'LaTeX-outline-level)
(setq outline-regexp (LaTeX-outline-regexp t))
(setq outline-heading-alist
(mapcar (lambda (x)
(cons (concat "\\" (nth 0 x)) (nth 1 x)))
LaTeX-section-list)))) Thank you for giving me great advice. However, now I have problems on moving headings up or down. First, Another one is about Easy Menu. On outshine.el#L2316-L2318, there are Regards, |
Well, you asked a good question in a good way, so you made it easy. I wish all users asked questions like you. :)
As the question on #48 asks, is it only the keybinding that doesn't work, or is it the command itself that doesn't work? I'm glad that the promotion and demotion commands work for you with LaTeX, but I don't know if commands that move headings and subtrees around will also work with LaTeX; if they are written to work with For any parts that don't, I'm not sure that Anyway, since I don't use LaTeX much, I'm mostly thinking out loud and rambling here. If there is anything to be done, it would probably need to be done by someone who actually uses LaTeX regularly. |
I'm glad to hear that.
The command itself works well. I try following 4 cases on a Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
outline-move-subtree-up()
#f(compiled-function (&optional arg) (interactive "P") #<bytecode 0x43a188b9>)(nil)
funcall-interactively(#f(compiled-function (&optional arg) (interactive "P") #<bytecode 0x43a188b9>) nil)
call-interactively(#f(compiled-function (&optional arg) (interactive "P") #<bytecode 0x43a188b9>) nil nil)
command-execute(#f(compiled-function (&optional arg) (interactive "P") #<bytecode 0x43a188b9>)) (2) When I call Debugger entered--Lisp error: (wrong-type-argument commandp outline-move-heading-up)
call-interactively(outline-move-heading-up nil nil)
command-execute(outline-move-heading-up) (4) With following setting as below, the keybinding (with-eval-after-load 'outshine
(define-key outshine-mode-map (kbd "M-S-<up>") #'outline-move-subtree-up)) Also I install dkwf branch of yuhan0's fork, and try (1--3) as above, then (1) and (2) work correctly, but (3) fails. So, I guess this problem is due to
AUCTeX --- a famous package for editing LaTeX documents --- supports outline features. The functions such as |
I get inconsistent behavior when demoting in emacs-lisp-mode -- sometimes it properly demotes a subtree, other times it inserts an additional space after the semicolons (rather than an additional semicolon). I haven't been able to pin down what causes it to work/break intermittently. |
@dkrieger I don't know why, but I've never tried to use |
@dkrieger Do errors appear with the functions themselves or with the |
My current workaround is to place this footer to each file:
@alphapapa Why is this trailing space needed? Can we get rid of it? And also why do we need to limit max level? |
@valff What's the major mode? |
@thblt It's emacs-lisp-mode. |
@valff On a quick test, I cannot reproduce the issue. Do you use the most recent version of outshine? If so, can you please provide instructions to reproduce from emacs -q? Thanks! |
@thblt Here is my snippet. Open it with ;;; -*- lexical-binding: t -*-
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el"
user-emacs-directory))
(bootstrap-version 5))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
(concat "https://raw.githubusercontent.com/"
"raxod502/straight.el/develop/install.el")
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
(require 'straight)
(straight-use-package 'outshine)
(require 'outshine)
(require 'outline)
(global-set-key (kbd "<C-left>") 'outline-promote)
(global-set-key (kbd "<C-right>") 'outline-demote)
;; Run M-x eval-buffer
;; Run M-x outshine-mode
;; Run M-x eval-buffer (don't know why is it needed)
;; * One <- Try <C-right> on this few times
;; ** Two Or the same result can be reproduced with outline-minor-mode only: (outline-minor-mode +1)
(setq outline-regexp ";; [*]\\{1,8\\} "); it is what outshine sets for elisp, right?
(global-set-key (kbd "<C-left>") 'outline-promote)
(global-set-key (kbd "<C-right>") 'outline-demote)
;; * One <- Try <C-right> on this few times
;; ** Two Clearly outline-promote/demote doesn't work well with the trailing space. |
Same as what you mentioned, the trailing white-space was the 'demote' and 'promote' bug trace core, that the origin mechinsm of outline to re-generate the head level sign was using 'substring' function manipulate the I given the 'around' advice for May I push one PR to this issue? Or does it conflict with the sake of designation of outshine utilities? |
@valff Thanks for the test case. If there is a bug in @c0001 Generally, we should avoid modifying variables defined in other packages, like @thblt Does all that make sense to you? I feel like the intertwining of |
@valff Thanks a lot for the MWE, and thank you for your patience. By my tests, the following snippet also triggers weird behavior: (outline-minor-mode +1)
(global-set-key (kbd "<C-left>") 'outline-promote)
(global-set-key (kbd "<C-right>") 'outline-demote)
(outline-minor-mode)
;; * One <- Try <C-right> on this few times
;; ** Two The semicolon syntax is also broken: ;;; One <- Try <C-right> on this few times
;;;; Two
;;;; Two prime
;;;;; Three
;;;; Two again Unlike your example, I don't set outline-regexp to simulate outshine behavior, so in my opinion the first thing that needs doing is getting the outline bug fixed. Notice I'm not saying there's no bug in outshine, but we shall tackle things in order. |
@alphapapa As a side note, and for the outshine part of the bug:
Outshine actually defines this variable and a few others it doesn't own, and “protects” them by restoring them to their original value when it's disabled. See the following bits: Lines 292 to 295 in 3e2aa44
Lines 969 to 970 in 3e2aa44
Lines 1029 to 1030 in 3e2aa44
|
For the trailing whitespace bug fix for: (defun temp/fix--outshine-advice-1 (orig-func &rest orig-args)
(let ((rtn (apply orig-func orig-args)))
(when (string-match-p " +$" rtn)
(setq
rtn
(replace-regexp-in-string
"\\( +\\)$" "" rtn)))
rtn))
(advice-add 'outshine-calc-outline-regexp
:around
#'temp/fix--outshine-advice-1) The trailing whitespace issue was mentioned as the previous post, if any confused for, that I post the raw (defun outline-invent-heading (head up)
"Create a heading by using heading HEAD as a template.
When UP is non-nil, the created heading will be one level above.
Otherwise, it will be one level below."
(save-match-data
;; Let's try to invent one by repeating or deleting the last char.
(let ((new-head (if up (substring head 0 -1)
>>>>>>>>>>>>>>>>>>>>>>>*_notice here_
(concat head (substring head -1)))))
(if (string-match (concat "\\`\\(?:" outline-regexp "\\)")
new-head)
;; Why bother checking that it is indeed higher/lower level ?
new-head
;; Didn't work, so ask what to do.
(read-string (format-message "%s heading for `%s': "
(if up "Parent" "Demoted") head)
head nil nil t))))) For referred face keywords fixing by altering the basic regexp generator: (defun temp/fix--outshine-fontify-headlines (orig-func &rest orig-args)
"Calculate heading regexps for font-lock mode."
(let* ((outline-regexp (car orig-args))
(outline-rgxp (substring outline-regexp 0 -7)) >>>>>> alter shrink counter
(heading-1-regexp
(format "%s%s%s%s%s%s"
outline-rgxp
"\\{1\\}" (format "[^%s]" outshine-regexp-base-char) "\\(.*" >>>>>> restruct font-lock face
(if outshine-fontify-whole-heading-line "\n?" "")
"\\)"))
(heading-2-regexp
(format "%s%s%s%s%s%s"
outline-rgxp
"\\{2\\}" (format "[^%s]" outshine-regexp-base-char) "\\(.*"
(if outshine-fontify-whole-heading-line "\n?" "")
"\\)"))
(heading-3-regexp
(format "%s%s%s%s%s%s"
outline-rgxp
"\\{3\\}" (format "[^%s]" outshine-regexp-base-char) "\\(.*"
(if outshine-fontify-whole-heading-line "\n?" "")
"\\)"))
(heading-4-regexp
(format "%s%s%s%s%s%s"
outline-rgxp
"\\{4\\}" (format "[^%s]" outshine-regexp-base-char) "\\(.*"
(if outshine-fontify-whole-heading-line "\n?" "")
"\\)"))
(heading-5-regexp
(format "%s%s%s%s%s%s"
outline-rgxp
"\\{5\\}" (format "[^%s]" outshine-regexp-base-char) "\\(.*"
(if outshine-fontify-whole-heading-line "\n?" "")
"\\)"))
(heading-6-regexp
(format "%s%s%s%s%s%s"
outline-rgxp
"\\{6\\}" (format "[^%s]" outshine-regexp-base-char) "\\(.*"
(if outshine-fontify-whole-heading-line "\n?" "")
"\\)"))
(heading-7-regexp
(format "%s%s%s%s%s%s"
outline-rgxp
"\\{7\\}" (format "[^%s]" outshine-regexp-base-char) "\\(.*"
(if outshine-fontify-whole-heading-line "\n?" "")
"\\)"))
(heading-8-regexp
(format "%s%s%s%s%s%s"
outline-rgxp
"\\{8\\}" (format "[^%s]" outshine-regexp-base-char) "\\(.*"
(if outshine-fontify-whole-heading-line "\n?" "")
"\\)"))
(font-lock-new-keywords
`((,heading-1-regexp 1 'outshine-level-1 t)
(,heading-2-regexp 1 'outshine-level-2 t)
(,heading-3-regexp 1 'outshine-level-3 t)
(,heading-4-regexp 1 'outshine-level-4 t)
(,heading-5-regexp 1 'outshine-level-5 t)
(,heading-6-regexp 1 'outshine-level-6 t)
(,heading-7-regexp 1 'outshine-level-7 t)
(,heading-8-regexp 1 'outshine-level-8 t))))
(add-to-list 'outshine-font-lock-keywords font-lock-new-keywords)
(font-lock-add-keywords nil font-lock-new-keywords)
(outshine-font-lock-flush)))
(advice-add 'outshine-fontify-headlines
:around
#'temp/fix--outshine-fontify-headlines) Further more patching to (defun outshine-set-outline-regexp-base ()
"Return the actual outline-regexp-base."
(if (and
(not (outshine-modern-header-style-in-elisp-p))
(eq major-mode 'emacs-lisp-mode))
(progn
(setq outshine-enforce-no-comment-padding-p t)
(setq outshine-regexp-base
outshine-oldschool-elisp-outline-regexp-base)
(setq-local outshine-regexp-base-char ";")) ;adding local base-char setting preventing recursive face map
(setq outshine-enforce-no-comment-padding-p nil)
(setq outshine-regexp-base
outshine-default-outline-regexp-base)
(setq-local outshine-regexp-base-char
(default-value 'outshine-regexp-base-char)))) There's no need to hacking with Thanks for reviewing -V- |
Yeah, and I think it would be good if we could avoid that. :) But fixing that would probably be quite an undertaking. |
This still doesn't work well, simply because outshine adds a final " " in The fix is trivial: remove the final space from the end Thanks for outshine mode, really great. |
I'm very sorry for my poor English and for not being familiar with Emacs Lisp.
I think,
outline-{promote, demote}
does not work well with outshine.outshine.el defines
outshine-change-level
with the docstringbut they are not defined in outshine.el. nor in outshine-org-cmds.el.
For example, for latex-mode, I set
outshine-promotion-headings
as follows:If I call
outline-demote
on\section{foo}
, then I get\sectionn{foo}
which is not expected.I think, by redefine
outline-{promote, demote}
as in outline-magic.el, we get expected one.Isn't it?
Thank you,
The text was updated successfully, but these errors were encountered: