Promote entry as first child node

Time:2020-2-26

“Real elisp” series aims to tell my experience of using elisp to customize Emacs, and invite Emacs to give me some advice — if there are many Emacs users, hahaha.

Preface

I use Emacs’s org mode to manage the progress of watching animation

Promote entry as first child node

Every weekday for lunch and dinner, I will arrange a meal animation. In order to watch different animations for each meal, my approach is:

  1. Select an animation from the end of the list (for example, select “ghost blade”);
  2. In this animation, create a sub node (such as “watch the 17th session”), set it to todo state, and set the schedule attribute to the lunch or dinner time of the next day;
  3. Move the entry of the animation to the position of the first child node of the current parent node (that is, to the top of Rhapsody of animals), so that the next animation will not be selected immediately.

To move to the first child node, you can cut and paste, or you can use the shortcut provided by org modeM-↑。 butM-↑You can only move up one level. If you want to move to the location of the first child node, you need to keep pressing this shortcut key. In order to simplify this step, I defined a new command and shortcut key.

Function definition

This function is very simple. It only needs to be called continuouslyM-↑The command corresponding to the shortcut key, until it ends with an error. In order to knowM-↑Which function corresponds to? In a buffer whose main mode is org mode, pressC-h kAnd press again.M-↑, you can see that its corresponding function isorg-move-subtree-up

Now, you can define this short and concise function

(defun up-to-top ()
  Move the current entry all the way to the top
  (interactive)
  (loop
   (org-move-subtree-up)))

I’ve bound it to the shortcut C-C o u

(define-key org-mode-map "\C-cou" 'up-to-top)

Epilogue

Using org mode to record the viewing progress of the animation will create many items like “watch XX words” under the animation items. If it’s “steelmaking” which is more than 60 episodes of animation, it’s still quite shocking and perplexing to see this series of sub items when it unfolds. In order to solve this problem, I have also customized some other functions in org mode. I will explain them next time.

Read the original text

Recommended Today

Incomplete delivery order log of SAP SD basic knowledge

Incomplete delivery order log of SAP SD basic knowledge   If we call the incomplete project log, the system checks whether the data in the outbound delivery is complete. From the generated list, we can directly jump to the screen of maintaining incomplete fields.   We can call log of incomplete items from delivery processing, […]