Last edit
Added:
> change-split-type-2 -->
Added:
> <-- M-1 change-split-type-2
Changed:
< change-split-type-3-v
to
> change-split-type-3-v -->
Changed:
< M-x 1 change-split-type-3-v
to
> <-- M-1 change-split-type-3-v
Changed:
< change-split-type-3-h
to
> change-split-type-3-h -->
Changed:
< M-x 1 change-split-type-3-h
to
> <-- M-1 change-split-type-3-h
Changed:
< +------------------------+ +------------------------+
< | A | \ | B |
< | | +-------+\ | |
< +------------------------+ +-------+/ +------------------------+
< | B | C | / | C | A |
< | | | | | |
< +------------------------+ +------------------------+
to
> +------------------------+ +------------------------+
> | A | \ | B |
> | | +-------+\ | |
> +------------------------+ +-------+/ +------------------------+
> | B | C | / | C | A |
> | | | | | |
> +------------------------+ +------------------------+
I use Emacs.
This is some Emacs extensive functions I wrote in my daily work.
Copy lines at point and paste them to mark
With prefix 1, copy but not paste. with prefix N, copy N lines from the point.
Copy words at point and paste them to mark
With prefix 1, copy but not paste.
with prefix N, copy N words from the point.
Copy paragraphs at point and paste them to mark
With prefix 1, copy but not paste.
with prefix N, copy N paragraphs from the point.
Copy string at point or region selected and paste them to mark
With prefix 1, copy but not paste.
with prefix N, copy N strings from the point.
Copy region between {[(<”\’\’”>)]\} and paste them to mark
Automatic due with nesting {[(<”\’\’”>)]} characters
Duplicate current line.
Used for temporary comment out line of code and replace it with something else.
This function splits frame into 4 windows, like following.
+-----------------------+----------------------+ | | | | | | | | | +-----------------------+----------------------+ | | | | | | | | | +-----------------------+----------------------+
I used to run shell mode in these windows.
Change split type in both 2 windows & 3 windows are rewritten. Everything is based on a common function {{ change-split-type }}.
(defun change-split-type (split-fn &optional arg)
"Change 3 window style from horizontal to vertical and vice-versa"
(let ((bufList (mapcar 'window-buffer (window-list))))
(select-window (get-largest-window))
(funcall split-fn arg)
(mapcar* 'set-window-buffer (window-list) bufList)))
Then I can implement {{ change-split-type-2 }} from it, which could rotate window splitting from vertically to horizontally and vice-versa.
change-split-type-2 -->
+------------------------+ +----------+-----------+
| | \ | | |
| | +-------+\ | | |
+------------------------+ +-------+/ | | |
| | / | | |
| | | | |
+------------------------+ +----------+-----------+
<-- M-1 change-split-type-2
+----------- +-----------+ +----------------------+
| | | \ | |
| | | +-------+\ | |
| | | +-------+/ +----------------------+
| | | / | |
| | | | |
+----------- +-----------+ +----------------------+
(defun change-split-type-2 (&optional arg)
"Changes splitting from vertical to horizontal and vice-versa"
(interactive "P")
(let ((split-type (lambda (&optional arg)
(delete-other-windows-internal)
(if arg (split-window-vertically)
(split-window-horizontally)))))
(change-split-type split-type arg)))
Change split type in 3 windows mode is more interesting now. You can change split type to vertical from anytime and exchange from 2 vertical types with a numeric prefix.
change-split-type-3-v -->
+----------- +-----------+ +----------- +-----------+
| | | / \ | | |
| | | /+-------+\ | | |
|------------| | \+-------+/ | |-----------|
| | | \ / | | |
| | | | | |
+----------- +-----------+ +----------- +-----------+
<-- M-1 change-split-type-3-v
(defun change-split-type-3-v (&optional arg)
"change 3 window style from horizon to vertical"
(interactive "P")
(change-split-type 'split-window-3-horizontally arg))
Same condition comes to horizontal mode.
change-split-type-3-h -->
+-----------------------+ +-----------------------+
| | | / \ | |
| | | /+-------+\ | |
+-----------------------+ \+-------+/ +-----------------------+
| | \ / | | |
| | | | |
+-----------------------+ +-----------------------+
<-- M-1 change-split-type-3-h
(defun change-split-type-3-h (&optional arg)
"change 3 window style from vertical to horizon"
(interactive "P")
(change-split-type 'split-window-3-vertically arg))
Roll 3 window buffers clockwise with windows split type unchanged
Roll 3 window buffers anti-clockwise with windows split type unchanged
+----------- +-----------+ +----------- +-----------+ | | C | \ | | A | | | | +-------+\ | | | | A |-----------| +-------+/ | B |-----------| | | B | / | | C | | | | | | | +----------- +-----------+ +----------- +-----------+ +------------------------+ +------------------------+ | A | \ | B | | | +-------+\ | | +------------------------+ +-------+/ +------------------------+ | B | C | / | C | A | | | | | | | +------------------------+ +------------------------+
Latest updates about these functions could be found in ThreeWindows
Exit from recursive shell logins automatically.
Rename buffer to the destination hostname in ssh login
Kill shell buffer after exit from shell process.
Rename buffer to the destination hostname in ssh login
Since I used to login to a lot of different machines in my daily work, I’d like to have the shell buffer name to represent the hostname of which I am working on.
Rename buffer to its previous name when user exit from a ssh login.
I do not just login to the destination machine from my GNU Emacs. Instead I used to login to a central host first, and then to login to any destinations from there.
So I need to have the shell buffer changes accordingly when I exit from a destination host and back to the central one.
This function is still in its babyhood. It could only work well in a single shell session. I am not sure how to handle multiple shell sessions simultaneously. And exit from a subshell is also a problem.
If anyone has good ideas, its warm welcome here!.
--8<-------------------------- §separator§ ------------------------>8-- ,----------- | DennyZhang: | If you are meaning invoke multiple shells, we basically | have two ways: Ctrl+u Alt+x shell, or (shell shell-buffer-name). | | You can check below for detail. | http://www.emacswiki.org/emacs/ShellMode#toc3 | EmacsWiki: Shell Mode | http://mjtsai.com/blog/2003/01/02/multiple_emacs_shell_buff/ | Michael Tsai - Blog - Multiple Emacs Shell Buffers | | Hi David, I have implemented bunches of lisp functions, which | serves as a handy shell extension. I use it everyday. Maybe you | can have a look. | http://hi.baidu.com/filebat/blog/item/262915d12a3299cf562c8481.html `-----------
Yes. It is the native way. But a host name is more meaningful than a sequence number. A similar problem occurs when find two files with the same name from different directories. It would be more meaningful to attach a parent directory name as prefix in the buffer name than to attach a sequence number. But I didn’t have time to make it.
Kill shell buffer after user exited from shell.
It is very ugly that the shell buffer will keep exist even user has already been exited from it. So I wrote this function to kill it for me.
I chose to use ‘set-process-sentinel’ function instead of monitor user commands. ‘set-process-sentinel’ is provided by shell mode itself. So it makes things simpler.
Enclose code for org-mode
#+begin_src some source code #+end_src
Enclose example for org-mode
#+BEGIN_EXAMPLE some examples #+END_EXAMPLE
Enclose code for Emacser.cn
#+BEGIN_HTML <pre lang="lisp" line="1"> some content </pre> #+END_HTML
Like isrc but enclose code at point for org-mode
Like iexp but enclose code at point for org-mode
Set string-at-point to =string-at-point=
Used in org-mode. For arbitrary content, select them first
Set string-at-point to string-at-point
Used in org-mode. For arbitrary content, select them first
Insert ‘: ‘ at each line of code
Used in org-mode. For operating on multiple lines, use prefix argument
Calculate matrix statistics by row & column. Then insert result into current buffer. Calculation is doing from a predefined shell script named as ‘matrixSum’
Bring content from specific buffer to current buffer.
Take the command at point, jump to another window, then paste it at prompt.
If the destination window is not in shell-mode, just paste it to the point over there. This makes jump useful in other text edit modes.
Delete all output from interpreter since the one before the last input. Because comint-delete-output just could not do it for you.
When overwrite-mode is on, display a red alert at the beginning of mode line. When overwrite-mode is off, remove the alert.
Welcome to the wiki. – DrewAdams
Thanks for your kind greeting. You’re so fast. BTW, can you advise me how to make the Lisp:dove-ext.el page becomes a download-able lisp file? I tried many times but always fail. – DavidYoung
Looks to me like you succeeded. – DrewAdams
I succeed when I pasted lisp code on the page directly, instead of replace that page with code file. – DavidYoung
Right. – DrewAdams