mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-02-03 23:40:14 +08:00
Merge remote-tracking branch 'LCTT/master'
This commit is contained in:
commit
5de1a933cc
115
sources/talk/20190314 A Look Back at the History of Firefox.md
Normal file
115
sources/talk/20190314 A Look Back at the History of Firefox.md
Normal file
@ -0,0 +1,115 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (A Look Back at the History of Firefox)
|
||||
[#]: via: (https://itsfoss.com/history-of-firefox)
|
||||
[#]: author: (John Paul https://itsfoss.com/author/john/)
|
||||
|
||||
A Look Back at the History of Firefox
|
||||
======
|
||||
|
||||
The Firefox browser has been a mainstay of the open-source community for a long time. For many years it was the default web browser on (almost) all Linux distros and the lone obstacle to Microsoft’s total dominance of the internet. This browser has roots that go back all the way to the very early days of the internet. Since this week marks the 30th anniversary of the internet, there is no better time to talk about how Firefox became the browser we all know and love.
|
||||
|
||||
### Early Roots
|
||||
|
||||
In the early 1990s, a young man named [Marc Andreessen][1] was working on his bachelor’s degree in computer science at the University of Illinois. While there, he started working for the [National Center for Supercomputing Applications][2]. During that time [Sir Tim Berners-Lee][3] released an early form of the web standards that we know today. Marc [was introduced][4] to a very primitive web browser named [ViolaWWW][5]. Seeing that the technology had potential, Marc and Eric Bina created an easy to install browser for Unix named [NCSA Mosaic][6]). The first alpha was released in June 1993. By September, there were ports to Windows and Macintosh. Mosaic became very popular because it was easier to use than other browsing software.
|
||||
|
||||
In 1994, Marc graduated and moved to California. He was approached by Jim Clark, who had made his money selling computer hardware and software. Clark had used Mosaic and saw the financial possibilities of the internet. Clark recruited Marc and Eric to start an internet software company. The company was originally named Mosaic Communications Corporation, however, the University of Illinois did not like [their use of the name Mosaic][7]. As a result, the company name was changed to Netscape Communications Corporation.
|
||||
|
||||
The company’s first project was an online gaming network for the Nintendo 64, but that fell through. The first product they released was a web browser named Mosaic Netscape 0.9, subsequently renamed Netscape Navigator. Internally, the browser project was codenamed mozilla, which stood for “Mosaic killer”. An employee created a cartoon of a [Godzilla like creature][8]. They wanted to take out the competition.
|
||||
|
||||
![Early Firefox Mascot][9]Early Mozilla mascot at Netscape
|
||||
|
||||
They succeed mightily. At the time, one of the biggest advantages that Netscape had was the fact that its browser looked and functioned the same on every operating system. Netscape described this as giving everyone a level playing field.
|
||||
|
||||
As usage of Netscape Navigator increase, the market share of NCSA Mosaic cratered. In 1995, Netscape went public. [On the first day][10], the stock started at $28, jumped to $75 and ended the day at $58. Netscape was without any rivals.
|
||||
|
||||
But that didn’t last for long. In the summer of 1994, Microsoft released Internet Explorer 1.0, which was based on Spyglass Mosaic which was based on NCSA Mosaic. The [browser wars][11] had begun.
|
||||
|
||||
Over the next few years, Netscape and Microsoft competed for dominance of the internet. Each added features to compete with the other. Unfortunately, Internet Explorer had an advantage because it came bundled with Windows. On top of that, Microsoft had more programmers and money to throw at the problem. Toward the end of 1997, Netscape started to run into financial problems.
|
||||
|
||||
### Going Open Source
|
||||
|
||||
![Mozilla Firefox][12]
|
||||
|
||||
In January 1998, Netscape open-sourced the code of the Netscape Communicator 4.0 suite. The [goal][13] was to “harness the creative power of thousands of programmers on the Internet by incorporating their best enhancements into future versions of Netscape’s software. This strategy is designed to accelerate development and free distribution by Netscape of future high-quality versions of Netscape Communicator to business customers and individuals.”
|
||||
|
||||
The project was to be shepherded by the newly created Mozilla Organization. However, the code from Netscape Communicator 4.0 proved to be very difficult to work with due to its size and complexity. On top of that, several parts could not be open sourced because of licensing agreements with third parties. In the end, it was decided to rewrite the browser from scratch using the new [Gecko][14]) rendering engine.
|
||||
|
||||
In November 1998, Netscape was acquired by AOL for [stock swap valued at $4.2 billion][15].
|
||||
|
||||
Starting from scratch was a major undertaking. Mozilla Firefox (initially nicknamed Phoenix) was created in June 2002 and it worked on multiple operating systems, such as Linux, Mac OS, Microsoft Windows, and Solaris.
|
||||
|
||||
The following year, AOL announced that they would be shutting down browser development. The Mozilla Foundation was subsequently created to handle the Mozilla trademarks and handle the financing of the project. Initially, the Mozilla Foundation received $2 million in donations from AOL, IBM, Sun Microsystems, and Red Hat.
|
||||
|
||||
In March 2003, Mozilla [announced pl][16][a][16][ns][16] to separate the suite into stand-alone applications because of creeping software bloat. The stand-alone browser was initially named Phoenix. However, the name was changed due to a trademark dispute with the BIOS manufacturer Phoenix Technologies, which had a BIOS-based browser named trademark dispute with the BIOS manufacturer Phoenix Technologies. Phoenix was renamed Firebird only to run afoul of the Firebird database server people. The browser was once more renamed to the Firefox that we all know.
|
||||
|
||||
At the time, [Mozilla said][17], “We’ve learned a lot about choosing names in the past year (more than we would have liked to). We have been very careful in researching the name to ensure that we will not have any problems down the road. We have begun the process of registering our new trademark with the US Patent and Trademark office.”
|
||||
|
||||
![Mozilla Firefox 1.0][18]Firefox 1.0 : [Picture Credit][19]
|
||||
|
||||
The first official release of Firefox was [0.8][20] on February 8, 2004. 1.0 followed on November 9, 2004. Version 2.0 and 3.0 followed in October 2006 and June 2008 respectively. Each major release brought with it many new features and improvements. In many respects, Firefox pulled ahead of Internet Explorer in terms of features and technology, but IE still had more users.
|
||||
|
||||
That changed with the release of Google’s Chrome browser. In the months before the release of Chrome in September 2008, Firefox accounted for 30% of all [browser usage][21] and IE had over 60%. According to StatCounter’s [January 2019 report][22], Firefox accounts for less than 10% of all browser usage, while Chrome has over 70%.
|
||||
|
||||
Fun Fact
|
||||
|
||||
Contrary to popular belief, the logo of Firefox doesn’t feature a fox. It’s actually a [Red Panda][23]. In Chinese, “fire fox” is another name for the red panda.
|
||||
|
||||
### The Future
|
||||
|
||||
As noted above, Firefox currently has the lowest market share in its recent history. There was a time when a bunch of browsers were based on Firefox, such as the early version of the [Flock browser][24]). Now most browsers are based on Google technology, such as Opera and Vivaldi. Even Microsoft is giving up on browser development and [joining the Chromium band wagon][25].
|
||||
|
||||
This might seem like quite a downer after the heights of the early Netscape years. But don’t forget what Firefox has accomplished. A group of developers from around the world have created the second most used browser in the world. They clawed 30% market share away from Microsoft’s monopoly, they can do it again. After all, they have us, the open source community, behind them.
|
||||
|
||||
The fight against the monopoly is one of the several reasons [why I use Firefox][26]. Mozilla regained some of its lost market-share with the revamped release of [Firefox Quantum][27] and I believe that it will continue the upward path.
|
||||
|
||||
What event from Linux and open source history would you like us to write about next? Please let us know in the comments below.
|
||||
|
||||
If you found this article interesting, please take a minute to share it on social media, Hacker News or [Reddit][28].
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/history-of-firefox
|
||||
|
||||
作者:[John Paul][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://itsfoss.com/author/john/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://en.wikipedia.org/wiki/Marc_Andreessen
|
||||
[2]: https://en.wikipedia.org/wiki/National_Center_for_Supercomputing_Applications
|
||||
[3]: https://en.wikipedia.org/wiki/Tim_Berners-Lee
|
||||
[4]: https://www.w3.org/DesignIssues/TimBook-old/History.html
|
||||
[5]: http://viola.org/
|
||||
[6]: https://en.wikipedia.org/wiki/Mosaic_(web_browser
|
||||
[7]: http://www.computinghistory.org.uk/det/1789/Marc-Andreessen/
|
||||
[8]: http://www.davetitus.com/mozilla/
|
||||
[9]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/03/Mozilla_boxing.jpg?ssl=1
|
||||
[10]: https://www.marketwatch.com/story/netscape-ipo-ignited-the-boom-taught-some-hard-lessons-20058518550
|
||||
[11]: https://en.wikipedia.org/wiki/Browser_wars
|
||||
[12]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/03/mozilla-firefox.jpg?resize=800%2C450&ssl=1
|
||||
[13]: https://web.archive.org/web/20021001071727/wp.netscape.com/newsref/pr/newsrelease558.html
|
||||
[14]: https://en.wikipedia.org/wiki/Gecko_(software)
|
||||
[15]: http://news.cnet.com/2100-1023-218360.html
|
||||
[16]: https://web.archive.org/web/20050618000315/http://www.mozilla.org/roadmap/roadmap-02-Apr-2003.html
|
||||
[17]: https://www-archive.mozilla.org/projects/firefox/firefox-name-faq.html
|
||||
[18]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/03/firefox-1.jpg?ssl=1
|
||||
[19]: https://www.iceni.com/blog/firefox-1-0-introduced-2004/
|
||||
[20]: https://en.wikipedia.org/wiki/Firefox_version_history
|
||||
[21]: https://en.wikipedia.org/wiki/Usage_share_of_web_browsers
|
||||
[22]: http://gs.statcounter.com/browser-market-share/desktop/worldwide/#monthly-201901-201901-bar
|
||||
[23]: https://en.wikipedia.org/wiki/Red_panda
|
||||
[24]: https://en.wikipedia.org/wiki/Flock_(web_browser
|
||||
[25]: https://www.windowscentral.com/microsoft-building-chromium-powered-web-browser-windows-10
|
||||
[26]: https://itsfoss.com/why-firefox/
|
||||
[27]: https://itsfoss.com/firefox-quantum-ubuntu/
|
||||
[28]: http://reddit.com/r/linuxusersgroup
|
||||
[29]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/03/mozilla-firefox.jpg?fit=800%2C450&ssl=1
|
@ -1,252 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (lujun9972)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Advanced Techniques for Reducing Emacs Startup Time)
|
||||
[#]: via: (https://blog.d46.us/advanced-emacs-startup/)
|
||||
[#]: author: (Joe Schafer https://blog.d46.us/)
|
||||
|
||||
Advanced Techniques for Reducing Emacs Startup Time
|
||||
======
|
||||
|
||||
Six techniques to reduce Emacs startup time by the author of the [Emacs Start Up Profiler][1].
|
||||
|
||||
tl;dr: Do these steps:
|
||||
|
||||
1. Profile with Esup.
|
||||
2. Adjust the garbage collection threshold.
|
||||
3. Autoload **everything** with use-package.
|
||||
4. Avoid helper functions which cause eager loads.
|
||||
5. See my Emacs [config][2] for an example.
|
||||
|
||||
|
||||
|
||||
### From .emacs.d Bankruptcy to Now
|
||||
|
||||
I recently declared my third .emacs.d bankruptcy and finished the fourth iteration of my Emacs configuration. The evolution was:
|
||||
|
||||
1. Copy and paste elisp snippets into `~/.emacs` and hope it works.
|
||||
2. Adopt a more structured approach with `el-get` to manage dependencies.
|
||||
3. Give up and outsource to Spacemacs.
|
||||
4. Get tired of Spacemacs intricacies and rewrite with `use-package`.
|
||||
|
||||
|
||||
|
||||
This article is a collection of tips collected during the 3 rewrites and from creating the Emacs Start Up Profiler. Many thanks to the teams behind Spacemacs, use-package and general. Without these dedicated voluteers, this task would be vastly more difficult.
|
||||
|
||||
### But What About Daemon Mode
|
||||
|
||||
Before we get started, let me acknowledge the common retort when optimizing Emacs: “Emacs is meant to run as a daemon so you’ll only start it once.” That’s all well and good except:
|
||||
|
||||
* Fast things feel nicer.
|
||||
* When customizing Emacs, you sometimes get into weird states that can be hard to recover from without restarting. For example, if you add a slow `lambda` function to your `post-command-hook`, it’s tough to remove it.
|
||||
* Restarting Emacs helps verify that customization will persist between sessions.
|
||||
|
||||
|
||||
|
||||
### 1\. Establish the Current and Best Possible Start Up Time
|
||||
|
||||
The first step is to measure the current start up time. The easy way is to display the information at startup which will show progress through the next steps.
|
||||
|
||||
```
|
||||
(add-hook 'emacs-startup-hook
|
||||
(lambda ()
|
||||
(message "Emacs ready in %s with %d garbage collections."
|
||||
(format "%.2f seconds"
|
||||
(float-time
|
||||
(time-subtract after-init-time before-init-time)))
|
||||
gcs-done)))
|
||||
```
|
||||
|
||||
Second, measure the best possible startup speed so you know what’s possible. Mine is 0.3 seconds.
|
||||
|
||||
```
|
||||
emacs -q --eval='(message "%s" (emacs-init-time))'
|
||||
|
||||
;; For macOS users:
|
||||
open -n /Applications/Emacs.app --args -q --eval='(message "%s" (emacs-init-time))'
|
||||
```
|
||||
|
||||
### 2\. Profile Emacs Startup for Easy Wins
|
||||
|
||||
The [Emacs StartUp Profiler][1] (ESUP) will give you detailed metrics for top-level expressions.
|
||||
|
||||
![esup.png][3]
|
||||
|
||||
Figure 1:
|
||||
|
||||
Emacs Start Up Profiler Screenshot
|
||||
|
||||
WARNING: Spacemacs users, ESUP currently chokes on the Spacemacs init.el file. Follow <https://github.com/jschaf/esup/issues/48> for updates.
|
||||
|
||||
### 3\. Set the Garbage Collection Threshold Higher during Startup
|
||||
|
||||
This saves about ****0.3 seconds**** on my configuration.
|
||||
|
||||
The default value for Emacs is 760kB which is extremely conservative on a modern machine. The real trick is to lower it back to something reasonable after initialization. This saves about 0.3 seconds on my init files.
|
||||
|
||||
```
|
||||
;; Make startup faster by reducing the frequency of garbage
|
||||
;; collection. The default is 800 kilobytes. Measured in bytes.
|
||||
(setq gc-cons-threshold (* 50 1000 1000))
|
||||
|
||||
;; The rest of the init file.
|
||||
|
||||
;; Make gc pauses faster by decreasing the threshold.
|
||||
(setq gc-cons-threshold (* 2 1000 1000))
|
||||
```
|
||||
|
||||
### 4\. Never require anything; autoload with use-package instead
|
||||
|
||||
The best way to make Emacs faster is to do less. Running `require` eagerly loads the underlying source file. It’s rare the you’ll need functionality immediately at startup time.
|
||||
|
||||
With [`use-package`][4], you declare which features you need from a package and `use-package` does the right thing. Here’s what it looks like:
|
||||
|
||||
```
|
||||
(use-package evil-lisp-state ; the Melpa package name
|
||||
|
||||
:defer t ; autoload this package
|
||||
|
||||
:init ; Code to run immediately.
|
||||
(setq evil-lisp-state-global nil)
|
||||
|
||||
:config ; Code to run after the package is loaded.
|
||||
(abn/define-leader-keys "k" evil-lisp-state-map))
|
||||
```
|
||||
|
||||
To see what packages Emacs currently has loaded, examine the `features` variable. For nice output see [lpkg explorer][5] or my variant in [abn-funcs-benchmark.el][6]. The output looks like:
|
||||
|
||||
```
|
||||
479 features currently loaded
|
||||
- abn-funcs-benchmark: /Users/jschaf/.dotfiles/emacs/funcs/abn-funcs-benchmark.el
|
||||
- evil-surround: /Users/jschaf/.emacs.d/elpa/evil-surround-20170910.1952/evil-surround.elc
|
||||
- misearch: /Applications/Emacs.app/Contents/Resources/lisp/misearch.elc
|
||||
- multi-isearch: nil
|
||||
- <many more>
|
||||
```
|
||||
|
||||
### 5\. Avoid Helper Functions to Set Up Modes
|
||||
|
||||
Often, Emacs packages will suggest running a helper function to set up keybindings. Here’s a few examples:
|
||||
|
||||
* `(evil-escape-mode)`
|
||||
* `(windmove-default-keybindings) ; Sets up keybindings.`
|
||||
* `(yas-global-mode 1) ; Complex snippet setup.`
|
||||
|
||||
|
||||
|
||||
Rewrite these with use-package to improve startup speed. These helper functions are really just sneaky ways to trick you into eagerly loading packages before you need them.
|
||||
|
||||
As an example, here’s how to autoload `evil-escape-mode`.
|
||||
|
||||
```
|
||||
;; The definition of evil-escape-mode.
|
||||
(define-minor-mode evil-escape-mode
|
||||
(if evil-escape-mode
|
||||
(add-hook 'pre-command-hook 'evil-escape-pre-command-hook)
|
||||
(remove-hook 'pre-command-hook 'evil-escape-pre-command-hook)))
|
||||
|
||||
;; Before:
|
||||
(evil-escape-mode)
|
||||
|
||||
;; After:
|
||||
(use-package evil-escape
|
||||
:defer t
|
||||
;; Only needed for functions without an autoload comment (;;;###autoload).
|
||||
:commands (evil-escape-pre-command-hook)
|
||||
|
||||
;; Adding to a hook won't load the function until we invoke it.
|
||||
;; With pre-command-hook, that means the first command we run will
|
||||
;; load evil-escape.
|
||||
:init (add-hook 'pre-command-hook 'evil-escape-pre-command-hook))
|
||||
```
|
||||
|
||||
For a much trickier example, consider `org-babel`. The common recipe is:
|
||||
|
||||
```
|
||||
(org-babel-do-load-languages
|
||||
'org-babel-load-languages
|
||||
'((shell . t)
|
||||
(emacs-lisp . nil)))
|
||||
```
|
||||
|
||||
This is bad because `org-babel-do-load-languages` is defined in `org.el`, which is over 24k lines of code and takes about 0.2 seconds to load. After examining the source code, `org-babel-do-load-languages` is simply requiring the `ob-<lang>` package like so:
|
||||
|
||||
```
|
||||
;; From org.el in the org-babel-do-load-languages function.
|
||||
(require (intern (concat "ob-" lang)))
|
||||
```
|
||||
|
||||
In the `ob-<lang>.el`, there’s only two methods we care about, `org-babel-execute:<lang>` and `org-babel-expand-body:<lang>`. We can autoload the org-babel functionality instead of `org-babel-do-load-languages` like so:
|
||||
|
||||
```
|
||||
;; Avoid `org-babel-do-load-languages' since it does an eager require.
|
||||
(use-package ob-python
|
||||
:defer t
|
||||
:ensure org-plus-contrib
|
||||
:commands (org-babel-execute:python))
|
||||
|
||||
(use-package ob-shell
|
||||
:defer t
|
||||
:ensure org-plus-contrib
|
||||
:commands
|
||||
(org-babel-execute:sh
|
||||
org-babel-expand-body:sh
|
||||
|
||||
org-babel-execute:bash
|
||||
org-babel-expand-body:bash))
|
||||
```
|
||||
|
||||
### 6\. Defer Packages you don’t need Immediately with Idle Timers
|
||||
|
||||
This saves about ****0.4 seconds**** for the 9 packages I defer.
|
||||
|
||||
Some packages are useful and you want them available soon, but are not essential for immediate editing. These modes include:
|
||||
|
||||
* `recentf`: Saves recent files.
|
||||
* `saveplace`: Saves point of visited files.
|
||||
* `server`: Starts Emacs daemon.
|
||||
* `autorevert`: Automatically reloads files that changed on disk.
|
||||
* `paren`: Highlight matching parenthesis.
|
||||
* `projectile`: Project management tools.
|
||||
* `whitespace`: Highlight trailing whitespace.
|
||||
|
||||
|
||||
|
||||
Instead of requiring these modes, ****load them after N seconds of idle time****. I use 1 second for the more important packages and 2 seconds for everything else.
|
||||
|
||||
```
|
||||
(use-package recentf
|
||||
;; Loads after 1 second of idle time.
|
||||
:defer 1)
|
||||
|
||||
(use-package uniquify
|
||||
;; Less important than recentf.
|
||||
:defer 2)
|
||||
```
|
||||
|
||||
### Optimizations that aren’t Worth It
|
||||
|
||||
Don’t bother byte-compiling your personal Emacs files. It saved about 0.05 seconds. Byte compiling causes difficult to debug errors when the source file gets out of sync with compiled file.
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://blog.d46.us/advanced-emacs-startup/
|
||||
|
||||
作者:[Joe Schafer][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://blog.d46.us/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://github.com/jschaf/esup
|
||||
[2]: https://github.com/jschaf/dotfiles/blob/master/emacs/start.el
|
||||
[3]: https://blog.d46.us/images/esup.png
|
||||
[4]: https://github.com/jwiegley/use-package
|
||||
[5]: https://gist.github.com/RockyRoad29/bd4ca6fdb41196a71662986f809e2b1c
|
||||
[6]: https://github.com/jschaf/dotfiles/blob/master/emacs/funcs/abn-funcs-benchmark.el
|
@ -0,0 +1,256 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (lujun9972)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Advanced Techniques for Reducing Emacs Startup Time)
|
||||
[#]: via: (https://blog.d46.us/advanced-emacs-startup/)
|
||||
[#]: author: (Joe Schafer https://blog.d46.us/)
|
||||
|
||||
降低 Emacs 启动时间的高级技术
|
||||
======
|
||||
|
||||
[Emacs Start Up Profiler][1] 的作者教你六项技术减少 Emacs 启动时间。
|
||||
|
||||
简而言之:做下面几个步骤:
|
||||
|
||||
1。使用 Esup 进行性能检测。
|
||||
2。调整垃圾回收的阀值。
|
||||
3。使用 usge-page 来自动(延迟)加载所有东西。
|
||||
4。不要使用会引起立即加载的辅助函数。
|
||||
5。参考我的 [配置 ][2]。
|
||||
|
||||
|
||||
|
||||
### 从 .emacs.d 破产到现在
|
||||
|
||||
我最近宣布了第三次 .emacs.d 破产并完成了第四次 Emacs 配置的迭代。演化过程为:
|
||||
|
||||
1。拷贝并粘贴 elisp 片段到 `~/.emacs` 中,希望它能工作。
|
||||
2。借助 `el-get` 来以更结构化的方式来管理依赖关系。
|
||||
3。放弃自己从零配置,以 Spacemacs 为基础。
|
||||
4。厌倦了 Spacemacs 的复杂性,基于 `use-package` 重写配置。
|
||||
|
||||
本文汇聚了三次重写和创建 `Emacs Start Up Profiler` 过程中的技巧。
|
||||
非常感谢 Spacemacs,use-package 等背后的团队。
|
||||
没有这些无私的志愿者,这项任务将会困难得多。
|
||||
|
||||
|
||||
### 不过守护进程模式又如何呢
|
||||
|
||||
在我们开始之前,让我声明一下常见的反对优化 Emacs 的观念:“Emacs 旨在作为守护进程来运行的,因此你只需要运行一次而已。”
|
||||
这个观点很好,只不过:
|
||||
|
||||
- 速度总是越快越好
|
||||
- 配置 Emacs 时,可能会有不得不通过重启 Emacs 的情况。例如,你可能为 `post-command-hook` 添加了一个运行缓慢的 `lambda` 函数,很难删掉它。
|
||||
- 重启 Emacs 能帮你验证不同会话之间是否还能保留配置
|
||||
|
||||
### 估算当前以及最佳的启动时间
|
||||
|
||||
第一步是衡量当前的启动时间。最简单的方法就是在启动时显示后续步骤进度的信息。
|
||||
|
||||
```
|
||||
(add-hook 'emacs-startup-hook
|
||||
(lambda ()
|
||||
(message "Emacs ready in %s with %d garbage collections."
|
||||
(format "%.2f seconds"
|
||||
(float-time
|
||||
(time-subtract after-init-time before-init-time)))
|
||||
gcs-done)))
|
||||
```
|
||||
|
||||
第二部,衡量最佳的启动速度,以便了解可能的情况。我的是 0.3 秒。
|
||||
|
||||
```
|
||||
emacs -q --eval='(message "%s" (emacs-init-time))'
|
||||
|
||||
;; For macOS users:
|
||||
open -n /Applications/Emacs.app --args -q --eval='(message "%s" (emacs-init-time))'
|
||||
```
|
||||
|
||||
### 2。检测 Emacs 启动指标对你大有帮助
|
||||
|
||||
[Emacs StartUp Profiler][1] (ESUP) 将会给你顶层语句执行的详细指标。
|
||||
|
||||
![esup.png][3]
|
||||
|
||||
|
||||
图 1: Emacs Start Up Profiler 截图
|
||||
|
||||
警告:Spacemacs 用户需要注意,ESUP 目前与 Spacemacs 的 init.el 文件有冲突。遵照 <https://github.com/jschaf/esup/issues/48> 上说的进行升级。
|
||||
|
||||
### 启动时调高垃圾回收的阀值
|
||||
|
||||
这为我节省了 **0.3 秒**。
|
||||
|
||||
Emacs 默认值是 760kB,这在现代机器看来及其的保守。
|
||||
真正的诀窍在于初始化完成后再把它降到合理的水平。
|
||||
这为了节省了 0.3 秒
|
||||
|
||||
```
|
||||
;; Make startup faster by reducing the frequency of garbage
|
||||
;; collection. The default is 800 kilobytes. Measured in bytes.
|
||||
(setq gc-cons-threshold (* 50 1000 1000))
|
||||
|
||||
;; The rest of the init file.
|
||||
|
||||
;; Make gc pauses faster by decreasing the threshold.
|
||||
(setq gc-cons-threshold (* 2 1000 1000))
|
||||
```
|
||||
|
||||
### 4。不要 require 任何东西,转而使用 use-package 来自动加载
|
||||
|
||||
让 Emacs 变坏的最好方法就是减少要做的事情。`require` 会立即加载源文件。
|
||||
但是很少会出现需要在启动阶段就立即需要这些功能的。
|
||||
|
||||
在 [`use-package`][4] 中你只需要声明好需要哪个包中的哪个功能,`use-package` 就会帮你完成正确的事情。
|
||||
它看起来是这样的:
|
||||
|
||||
```
|
||||
(use-package evil-lisp-state ; the Melpa package name
|
||||
|
||||
:defer t ; autoload this package
|
||||
|
||||
:init ; Code to run immediately.
|
||||
(setq evil-lisp-state-global nil)
|
||||
|
||||
:config ; Code to run after the package is loaded.
|
||||
(abn/define-leader-keys "k" evil-lisp-state-map))
|
||||
```
|
||||
|
||||
可以通过查看 `features` 变量来查看 Emacs 现在加载了那些包。
|
||||
想要更好看的输出可以使用 [lpkg explorer][5] 或者我在 [abn-funcs-benchmark.el][6] 中的变体。
|
||||
输出看起来类似这样的:
|
||||
|
||||
```
|
||||
479 features currently loaded
|
||||
- abn-funcs-benchmark: /Users/jschaf/.dotfiles/emacs/funcs/abn-funcs-benchmark.el
|
||||
- evil-surround: /Users/jschaf/.emacs.d/elpa/evil-surround-20170910.1952/evil-surround.elc
|
||||
- misearch: /Applications/Emacs.app/Contents/Resources/lisp/misearch.elc
|
||||
- multi-isearch: nil
|
||||
- <many more>
|
||||
```
|
||||
|
||||
### 5。不要使用辅助函数来设置模式
|
||||
|
||||
通常,Emacs packages 会建议通过运行一个辅助函数来设置键绑定。下面是一些例子:
|
||||
|
||||
* `(evil-escape-mode)`
|
||||
* `(windmove-default-keybindings) ; 设置快捷键。`
|
||||
* `(yas-global-mode 1) ;复杂的片段配置。`
|
||||
|
||||
可以通过 use-package 来对此进行重构以提高启动速度。这些辅助函数只会让你立即加载那些尚用不到的 package。
|
||||
|
||||
下面这个例子告诉你如何自动加载 `evil-escape-mode`。
|
||||
|
||||
```
|
||||
;; The definition of evil-escape-mode.
|
||||
(define-minor-mode evil-escape-mode
|
||||
(if evil-escape-mode
|
||||
(add-hook 'pre-command-hook 'evil-escape-pre-command-hook)
|
||||
(remove-hook 'pre-command-hook 'evil-escape-pre-command-hook)))
|
||||
|
||||
;; Before:
|
||||
(evil-escape-mode)
|
||||
|
||||
;; After:
|
||||
(use-package evil-escape
|
||||
:defer t
|
||||
;; Only needed for functions without an autoload comment (;;;###autoload).
|
||||
:commands (evil-escape-pre-command-hook)
|
||||
|
||||
;; Adding to a hook won't load the function until we invoke it.
|
||||
;; With pre-command-hook, that means the first command we run will
|
||||
;; load evil-escape.
|
||||
:init (add-hook 'pre-command-hook 'evil-escape-pre-command-hook))
|
||||
```
|
||||
|
||||
下面来看一个关于 `org-babel` 的例子,这个例子更为复杂。我们通常的配置时这样的:
|
||||
|
||||
```
|
||||
(org-babel-do-load-languages
|
||||
'org-babel-load-languages
|
||||
'((shell . t)
|
||||
(emacs-lisp . nil)))
|
||||
```
|
||||
|
||||
这种不是个好的配置,因为 `org-babel-do-load-languages` 定义在 `org.el` 中,而该文件有超过 2 万 4 千行的代码,需要花 0.2 秒来加载。
|
||||
通过查看源代码可以看到 `org-babel-do-load-languages` 仅仅只是加载 `ob-<lang>` 包而已,像这样:
|
||||
|
||||
```
|
||||
;; From org.el in the org-babel-do-load-languages function.
|
||||
(require (intern (concat "ob-" lang)))
|
||||
```
|
||||
|
||||
而在 `ob-<lang>.el` 文件中,我们只关心其中的两个方法 `org-babel-execute:<lang>` 和 `org-babel-expand-body:<lang>`。
|
||||
我们可以延时加载 org-babel 相关功能而无需调用 `org-babel-do-load-languages`,像这样:
|
||||
|
||||
```
|
||||
;; Avoid `org-babel-do-load-languages' since it does an eager require.
|
||||
(use-package ob-python
|
||||
:defer t
|
||||
:ensure org-plus-contrib
|
||||
:commands (org-babel-execute:python))
|
||||
|
||||
(use-package ob-shell
|
||||
:defer t
|
||||
:ensure org-plus-contrib
|
||||
:commands
|
||||
(org-babel-execute:sh
|
||||
org-babel-expand-body:sh
|
||||
|
||||
org-babel-execute:bash
|
||||
org-babel-expand-body:bash))
|
||||
```
|
||||
|
||||
### 6。使用惰性定时器 (idle timer) 来推迟加载非立即需要的包
|
||||
|
||||
我推迟加载了 9 个包,这帮我节省了 **0.4 秒**。
|
||||
|
||||
有些包特别有用,你希望可以很快就能使用它们,但是它们本身在 Emacs 启动过程中又不是必须的。这些 mode 包括:
|
||||
|
||||
- `recentf`: 保存最近的编辑过的那些文件。
|
||||
- `saveplace`: 保存访问过文件的光标位置。
|
||||
- `server`: 开启 Emacs 守护进程。
|
||||
- `autorevert`: 自动重载被修改过的文件。
|
||||
- `paren`: 高亮匹配的括号。
|
||||
- `projectile`: 项目管理工具。
|
||||
- `whitespace`: 高亮行尾的空格。
|
||||
|
||||
不要 require 这些 mode,** 而是等到空闲 N 秒后再加载它们**。
|
||||
我在 1 秒后加载那些比较重要的包,在 2 秒后加载其他所有的包。
|
||||
|
||||
```
|
||||
(use-package recentf
|
||||
;; Loads after 1 second of idle time.
|
||||
:defer 1)
|
||||
|
||||
(use-package uniquify
|
||||
;; Less important than recentf.
|
||||
:defer 2)
|
||||
```
|
||||
|
||||
### 不值得的优化
|
||||
|
||||
不要费力把你的 Emacs 配置文件编译成字节码了。这只节省了大约 0.05 秒。
|
||||
把配置文件编译成字节码可能导致源文件与编译后的文件不匹配从而导致难以出现错误调试。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://blog.d46.us/advanced-emacs-startup/
|
||||
|
||||
作者:[Joe Schafer][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://blog.d46.us/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://github.com/jschaf/esup
|
||||
[2]: https://github.com/jschaf/dotfiles/blob/master/emacs/start.el
|
||||
[3]: https://blog.d46.us/images/esup.png
|
||||
[4]: https://github.com/jwiegley/use-package
|
||||
[5]: https://gist.github.com/RockyRoad29/bd4ca6fdb41196a71662986f809e2b1c
|
||||
[6]: https://github.com/jschaf/dotfiles/blob/master/emacs/funcs/abn-funcs-benchmark.el
|
@ -3,32 +3,33 @@
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Asynchronous rsync with Emacs, dired and tramp.)
|
||||
[#]: subject: (Asynchronous rsync with Emacs,dired and tramp。)
|
||||
[#]: via: (https://vxlabs.com/2018/03/30/asynchronous-rsync-with-emacs-dired-and-tramp/)
|
||||
[#]: author: (cpbotha https://vxlabs.com/author/cpbotha/)
|
||||
|
||||
Asynchronous rsync with Emacs, dired and tramp.
|
||||
在 Emacs 的 dired 和 tramp 中异步运行 rsync
|
||||
======
|
||||
|
||||
[tmtxt-dired-async][1] by [Trần Xuân Trường][2] is an unfortunately lesser known Emacs package which extends dired, the Emacs file manager, to be able to run rsync and other commands (zip, unzip, downloading) asynchronously.
|
||||
[Trần Xuân Trường][2] 写的 [tmtxt-dired-async][1] 是一个不为人知的 Emacs 包,它可以扩展 dired(Emacs 内置的文件管理器),使之可以异步地运行 rsync 等其他命令 (例如 zip,unzip,downloading)。
|
||||
|
||||
This means you can copy gigabytes of directories around whilst still happily continuing with all of your other tasks in the Emacs operating system.
|
||||
这意味着你可以拷贝成 G 的目录而不影响 Emacs 的其他任务。
|
||||
|
||||
It has a feature where you can add any number of files from different locations into a wait list with `C-c C-a`, and then asynchronously rsync the whole wait list into a final destination directory with `C-c C-v`. This alone is worth the price of admission.
|
||||
它的一个功能时让你可以通过 `C-c C-a` 从不同位置添加任意多的文件到一个等待列表中,然后按下 `C-c C-v` 异步地使用 rsync 将整个等待列表中的文件同步到目标目录中 . 光这个功能就值得一试了。
|
||||
|
||||
例如这里将 arduino 1.9 beta 存档同步到另一个目录中:
|
||||
|
||||
For example here it is pointlessly rsyncing the arduino 1.9 beta archive to another directory:
|
||||
|
||||
[![][3]][4]
|
||||
|
||||
When the process is complete, the window at the bottom will automatically be killed after 5 seconds. Here is a separate session right after the asynchronous unzipping of the above-mentioned arduino archive:
|
||||
整个进度完成后,底部的窗口会在 5 秒后自动退出。下面时异步解压上面的 arduino 存档后出现的另一个会话:
|
||||
|
||||
[![][5]][6]
|
||||
|
||||
This package has further increased the utility of my dired configuration.
|
||||
这个包进一步增加了我 dired 配置的实用性。
|
||||
|
||||
I just contributed [a pull request that enables tmtxt-dired-async to rsync to remote tramp-based directories][7], and I immediately used this new functionality to sort a few gigabytes of new photos onto the Linux server.
|
||||
我刚刚贡献了 [一个 pull request 来允许 tmtxt-dired-async 同步到远程 tramp 目录中 ][7],而且我立即使用该功能来将成 G 的新照片传输到 Linux 服务器上。
|
||||
|
||||
To add tmtxt-dired-async to your config, download [tmtxt-async-tasks.el][8] (a required library) and [tmtxt-dired-async.el][9] (check that my PR is in there if you plan to use this with tramp) into your `~/.emacs.d/` and add the following to your config:
|
||||
若你想配置 tmtxt-dired-async,下载 [tmtxt-async-tasks.el][8] (被依赖的库) 以及 [tmtxt-dired-async.el][9] (若你想让它支持 tramp,请确保我的 PR 以及被合并) 到 =~/.emacs.d/= 目录中,然后添加下面配置:
|
||||
|
||||
```
|
||||
;; no MELPA packages of this, so we have to do a simple check here
|
||||
@ -50,7 +51,7 @@ To add tmtxt-dired-async to your config, download [tmtxt-async-tasks.el][8] (a r
|
||||
(define-key dired-mode-map (kbd "C-c C-q") 'tda/download-to-current-dir))
|
||||
```
|
||||
|
||||
Enjoy!
|
||||
祝你开心!
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
@ -7,23 +7,23 @@
|
||||
[#]: via: (https://www.badykov.com/emacs/2018/08/26/be-productive-with-org-mode/)
|
||||
[#]: author: (Ayrat Badykov https://www.badykov.com)
|
||||
|
||||
Be productive with Org-mode
|
||||
高效使用 Org-mode
|
||||
======
|
||||
|
||||
|
||||
![org-mode-collage][1]
|
||||
|
||||
### Introduction
|
||||
### 简介
|
||||
|
||||
In my [previous post about emacs][2] I mentioned [Org-mode][3], a note manager and organizer. In this post, I’ll describe my day-to-day Org-mode use cases.
|
||||
在我 [前篇关于 Emacs 的文章中 ][2] 我提到了 [Org-mode][3],一个笔记管理工具和组织工具。文本,我将会描述一下我日常的 Org-mode 使用案例。
|
||||
|
||||
### Notes and to-do lists
|
||||
### 笔记和代办列表
|
||||
|
||||
First and foremost, Org-mode is a tool for managing notes and to-do lists and all work in Org-mode is centered around writing notes in plain text files. I manage several kinds of notes using Org-mode.
|
||||
首先而且最重要的是,Org-mode 是一个管理笔记和待办列表的工具,Org-mode 的所有工具都聚焦于使用纯文本文件记录笔记。我使用 Org-mode 管理多种笔记。
|
||||
|
||||
#### General notes
|
||||
#### 一般性笔记
|
||||
|
||||
The most basic Org-mode use case is writing simple notes about things that you want to remember. For example, here are my notes about things I’m learning right now:
|
||||
Org-mode 最基本的应用场景就是以笔记的形式记录下你想记住的事情。比如,下面是我正在学习的笔记内容:
|
||||
|
||||
```
|
||||
* Learn
|
||||
@ -51,21 +51,19 @@ The most basic Org-mode use case is writing simple notes about things that you w
|
||||
*** Read Erlang in Anger
|
||||
```
|
||||
|
||||
How it looks using [org-bullets][4]:
|
||||
借助 [org-bullets][4] 它看起来是这样的:
|
||||
|
||||
![notes][5]
|
||||
|
||||
In this simple example you can see some of the Org-mode features:
|
||||
在这个简单的例子中,你能看到 Org-mode 的一些功能:
|
||||
|
||||
* nested notes
|
||||
* links
|
||||
* lists with checkboxes
|
||||
- 笔记允许嵌套
|
||||
- 链接
|
||||
- 带复选框的列表
|
||||
|
||||
#### 项目待办
|
||||
|
||||
|
||||
#### Project todos
|
||||
|
||||
Often when I’m working on some task I notice things that I can improve or fix. Instead of leaving TODO comment in source code files (bad smell) I use [org-projectile][6] which allows me to write TODO items with a single shortcut in a separate file. Here’s an example of this file:
|
||||
我在工作时时常会发现一些能够改进或修复的事情。我并不会在代码文件中留下 TODO 注释 (坏味道),相反我使用 [org-projectile][6] 来在另一个文件中记录一个 TODO 事项,并留下一个快捷方式。下面是一个该文件的例子:
|
||||
|
||||
```
|
||||
* [[elisp:(org-projectile-open-project%20"mana")][mana]] [3/9]
|
||||
@ -102,24 +100,24 @@ Often when I’m working on some task I notice things that I can improve or fix.
|
||||
CLOSED: [2018-08-26 Вс 11:48]
|
||||
```
|
||||
|
||||
How it looks in Emacs:
|
||||
它看起来是这样的:
|
||||
|
||||
![project-todos][7]
|
||||
|
||||
In this example you can see more Org mode features:
|
||||
本例中你能看到更多的 Org mode 功能:
|
||||
|
||||
* todo items have states - `TODO`, `DONE`. You can define your own states (`WAITING` etc)
|
||||
* closed items have `CLOSED` timestamp
|
||||
* some items have priorities - A, B, C.
|
||||
* links can be internal (`[[file:~/...]`)
|
||||
- todo 列表具有 `TODO`,`DONE` 两个状态。你还可以定义自己的状态 (`WAITING` 等)
|
||||
- 关闭的事项有 `CLOSED` 时间戳
|
||||
- 有些事项有优先级 - A,B,C。
|
||||
- 链接可以指向文件内部 (`[[file:~/。..]`)
|
||||
|
||||
|
||||
|
||||
#### Capture templates
|
||||
#### 捕获模板
|
||||
|
||||
As described in Org-mode’s documentation, capture lets you quickly store notes with little interruption of your workflow.
|
||||
正如 Org-mode 的文档中所描述的,capture 可以在不怎么干扰你工作流的情况下让你快速存储笔记。
|
||||
|
||||
I configured several capture templates which help me to quickly create notes about things that I want to remember.
|
||||
我配置了许多捕获模板,可以帮我快速记录想要记住的事情。
|
||||
|
||||
```
|
||||
(setq org-capture-templates
|
||||
@ -139,42 +137,42 @@ I configured several capture templates which help me to quickly create notes abo
|
||||
"* %^{book name} by %^{author} %^g")))
|
||||
```
|
||||
|
||||
For a book note I should add its name and its author, for a movie note I should add tags etc.
|
||||
做书本记录时我需要记下它的名字和作者,做电影记录时我需要记下标签,等等。
|
||||
|
||||
### Planning
|
||||
### 规划
|
||||
|
||||
Another great feature of Org-mode is that you can use it as a day planner. Let’s see an example of one of my days:
|
||||
Org-mode 的另一个超棒的功能是你可以用它来作日常规划。让我们来看一个例子:
|
||||
|
||||
![schedule][8]
|
||||
|
||||
I didn’t give a lot of thought to this example, it’s my real file for today. It doesn’t look like much but it helps to spend your time on things that important to you and fight with procrastination.
|
||||
我没有挖空心思虚构一个例子,这就是我现在真实文件的样子。它看起来内容并不多,但它有助于你花时间在在重要的事情上并且帮你对抗拖延症。
|
||||
|
||||
#### Habits
|
||||
#### 习惯
|
||||
|
||||
From Org mode’s documentation, Org has the ability to track the consistency of a special category of TODOs, called “habits”. I use this feature along with day planning when I want to create new habits:
|
||||
根据 Org mode 的文档,Org 能够跟踪一种特殊的代办事情,称为 “习惯”。当我想养成新的习惯时,我会将该功能与日常规划功能一起连用:
|
||||
|
||||
![habits][9]
|
||||
|
||||
As you can see currently I’m trying to wake early every day and workout once in two days. Also, it helped to start reading books every day.
|
||||
你可以看到,目前我在尝试每天早期并且每两天锻炼一次。另外,它也有助于让我每天阅读书籍。
|
||||
|
||||
#### Agenda views
|
||||
#### 议事日程视图
|
||||
|
||||
Last but not least I use agenda views. Todo items can be scattered throughout different files (in my case daily plan and habits are in separate files), agenda views give an overview of all todo items:
|
||||
最后,我还使用议事日程视图功能。待办事项可能分散在不同文件中(比如我就是日常规划和习惯分散在不同文件中),议事日程视图可以提供所有待办事项的总览:
|
||||
|
||||
![agenda][10]
|
||||
|
||||
### More Org mode features
|
||||
### 更多 Org mode 功能
|
||||
|
||||
+ 手机应用 ([Android][https://play.google.com/store/apps/details?id=com.orgzly&hl=en],[ios][https://itunes.apple.com/app/id1238649962])
|
||||
|
||||
+ [将 Org mode 文档导出为其他格式 ][https://orgmode.org/manual/Exporting.html](html,markdown,pdf,latex etc)
|
||||
|
||||
+ 使用 [ledger][https://github.com/ledger/ledger-mode] [追踪财务状况 ][https://orgmode.org/worg/org-tutorials/weaving-a-budget.html]
|
||||
|
||||
|
||||
+ Smartphone apps (Android, ios)
|
||||
### 总结
|
||||
|
||||
+ Exporting Org mode files into different formats (html, markdown, pdf, latex etc)
|
||||
|
||||
+ Tracking Finances with ledger
|
||||
|
||||
### Conclusion
|
||||
|
||||
In this post, I described a small subset of Org-mode’s extensive functionality that helps me be productive every day, spending time on things that important to me.
|
||||
本文我描述了 Org-mode 广泛功能中的一小部分,我每天都用它来提高工作效率,把时间花在重要的事情上。
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
Loading…
Reference in New Issue
Block a user