Merge remote-tracking branch 'LCTT/master'

This commit is contained in:
Xingyu Wang 2020-11-28 14:16:32 +08:00
commit e55c8e1c4e
7 changed files with 720 additions and 183 deletions

View File

@ -1,5 +1,5 @@
[#]: collector: (lujun9972) [#]: collector: (lujun9972)
[#]: translator: ( ) [#]: translator: (mengxinayan)
[#]: reviewer: ( ) [#]: reviewer: ( )
[#]: publisher: ( ) [#]: publisher: ( )
[#]: url: ( ) [#]: url: ( )
@ -59,7 +59,7 @@ via: https://opensource.com/article/20/10/influence-open-source
作者:[Joshua Pearce][a] 作者:[Joshua Pearce][a]
选题:[lujun9972][b] 选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID) 译者:[萌新阿岩](https://github.com/mengxinayan)
校对:[校对者ID](https://github.com/校对者ID) 校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -0,0 +1,85 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (4 questions about AI ethics and how open source can help)
[#]: via: (https://opensource.com/article/20/11/ai-ethics)
[#]: author: (Sahana Sreeram https://opensource.com/users/sahanasreeram01gmailcom)
4 questions about AI ethics and how open source can help
======
Open source resources could provide effective solutions to some key
ethical considerations for artificial intelligence.
![A robot arm illustration][1]
As a high school student, I've become very interested in artificial intelligence (AI), which is emerging as one of the most impactful innovations of recent times. This past summer, I was selected for the [AI4ALL][2] program, where we learned how to develop AI systems using Python.
For my final project, I created an object-detection program and integrated it with a virtual drone simulation. Throughout the project, I was able to use open source frameworks, including [TensorFlow][3], [Keras][4], [Scikit-learn][5], and [PyTorch][6], to aid in developing the object-detection machine learning (ML) algorithm process.
By doing this project and using other open source frameworks like [Linux][7], [Apache Kafka][8], and [ElasticSearch][9], I realized the impact of open source technologies on AI system development. Access to these powerful, flexible technologies enables people to experiment with and develop AI systems.
I discovered another important aspect of AI when I attended a seminar at [William & Mary][10] about AI and ethics. As we discussed some of the ethical concerns surrounding AI systems, I started wondering: How do I make sure that the systems I'm developing are ethical?
To answer my question, I interviewed three experts: [Alon Kaufman][11], PhD, CEO of Duality Technologies; [Iria Giuffrida][12], PhD, a law professor at William & Mary; and an executive in the fintech industry (name kept confidential upon request). I am very grateful to these experts for giving me their valuable time, fueling my curiosity, and inspiring me with their journeys in this field.
### How important of a role does ethics currently play in AI systems?
As more advances are made with AI, society is starting to appreciate the importance of ethical implications. However, the discussions about ethical values in AI system development are still an academic exercise, Dr. Kaufman says. Today, much of AI, and especially ML models, remains a "black box" because advanced algorithms and complex AI technologies (such as deep learning) produce models that are not self-explainable. Without having explainable AI/ML models, it's hard to introduce ethical considerations into the conversation. 
For Dr. Kaufman, the industry's focus today is on data security and protection. As more smart technology is developed, it's getting easier to acquire data. The large amounts of data handled in AI systems make them vulnerable to cyber breaches.
While it is certainly vital to build data protection measures for AI systems, it is becoming critical to shift the focus to other ethical implications, such as privacy and machine bias.
### Is ethical AI development a good goal for the future, or is it wishful thinking?
The short answer is that it is a reasonable goal to create ethical AI systems, but it will take time.
"Ethics" is a difficult concept to define. One approach is to look at ethics through a three-pronged methodology: security, privacy, and fairness. Most of the industry is now focused on security, and a practical next step could be to address the issues of privacy and ensuring data anonymity. "Privacy-enhancing technologies, such as secure computing and [synthetic data][13] could offer assistance in this process," explains Dr. Kaufman. Only after finding solutions to the security and privacy areas of ethics is it reasonable to venture into machine fairness and bias.
There are many factors to consider in the development of unbiased AI. "The first step is the deployment of active-learning models into society, followed by the actual development of [fair systems][14]," says the fintech industry expert. He explains that when ML equipped with active learning is deployed, society's own biases are often imposed on the model, even unknowingly, creating very flawed systems. When developers create AI systems, their preconceived notions must never be injected into the system code, says Dr. Kaufman. These are some of the key areas that must be addressed in developing unbiased models.
### How early should students be exposed to ethical considerations in AI/ML?
It's increasingly important to learn not only about computer science principles but also about how to build ethical models. Professor Giuffrida says computer scientists and AI developers have not explicitly been trained to think about the ethics behind their systems. This is why the development of bias-proof systems cannot be a linear process, she says; they must go through multiple review levels to minimize injecting bias in the machine process.
Professor Giuffrida emphasizes that AI development should be treated as an interdisciplinary study, meaning that it is not just developers who are in charge of creating accurate and ethical systems—that's an enormous responsibility to put on one group. But introducing ethical concepts to aspiring AI engineers at a foundational level could accelerate building sustainable, functional, and ethical systems.
### Will ethics come at the expense of innovation?
This was the main question I kept coming back to throughout the interviews. During the AI4ALL course, we explored the recent [Genderify fiasco][15], which was AI software intended to identify a user's gender based on several data points, including name, email address, and username. When launched for public use, the results were highly inaccurate—for example, the name "Meghan Smith" was assigned female, but "Dr. Meghan Smith" was assigned male. These biases led to the service's failure. More comprehensive ethical reviews and tests conducted before launch could make this type of product successful, at least initially.
All three experts voiced the idea that ethical boundaries are becoming necessary. According to the fintech executive, "Reasonable ethical constraints will not limit innovation—companies must eventually figure out how to innovate within these boundaries." In this fashion, ethical considerations could increase sustainability and success for a product—rather than putting a complete stop to AI development. Venture capitalist Rob Toews offered an interesting perspective on [regulating AI][16], and I recommend this article if you want to learn more about this topic.
Ultimately, introducing ethics into pure AI is a daunting but necessary step to secure AI's viability in our world. Open source resources could provide effective solutions to some key ethical considerations, including comprehensive system testing. For example, the [AI Fairness 360][17] open source toolkit by IBM assesses discrimination and biases in ML models. Open source communities have the ability to develop tools like this to provide greater coverage and support for ethical AI systems. In the meantime, I believe it is my generation's responsibility to build bridges between creating revolutionary AI technologies and considering ethical implications that will stand the test of time.
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/11/ai-ethics
作者:[Sahana Sreeram][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://opensource.com/users/sahanasreeram01gmailcom
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/robot_arm_artificial_ai.png?itok=8CUU3U_7 (A robot arm illustration)
[2]: https://ai-4-all.org/
[3]: https://www.tensorflow.org/
[4]: https://keras.io/
[5]: https://scikit-learn.org/stable/
[6]: https://pytorch.org/
[7]: https://www.linux.org/
[8]: https://kafka.apache.org/
[9]: https://www.elastic.co/
[10]: https://www.wm.edu/
[11]: https://www.linkedin.com/in/alon-kaufman-24067b154/
[12]: https://law2.wm.edu/faculty/bios/fulltime/igiuffrida.php
[13]: https://en.wikipedia.org/wiki/Synthetic_data
[14]: https://en.wikipedia.org/wiki/Fairness_(machine_learning)
[15]: https://www.theverge.com/2020/7/29/21346310/ai-service-gender-verification-identification-genderify
[16]: https://www.forbes.com/sites/robtoews/2020/06/28/here-is-how-the-united-states-should-regulate-artificial-intelligence/?sh=1c242ebc7821
[17]: https://aif360.mybluemix.net/

View File

@ -0,0 +1,87 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Comparing the similarities and differences between inner source and open source)
[#]: via: (https://opensource.com/article/20/11/inner-source)
[#]: author: (Nithya Ruff https://opensource.com/users/nithyaruff)
Comparing the similarities and differences between inner source and open source
======
Open source principles can be applied within a company to access the
benefits of collaborative development. Here's how.
![two women kanban brainstorming and brainmapping with post-it notes on a whiteboard ][1]
Open source software (OSS) has been around since the 1990s and has thrived, quickly growing to become mainstream. It is now more well understood around the world than it has ever been before. Some refer to it as FOSS to highlight the Freedom part of open source (Free and Open Source Software). And in 2014, at OSCON, the term "inner source" was debuted, and people started talking about how to use the principles of open source, but inside of a company. It raised several questions for those unfamiliar with the term, which I hope to answer with this article. For example, what is similar about the two, what is different, the company roles involved in the two, is inner source taking the energy away from open source, etc. These are all fair questions, and as my organization practices both and is involved in both movements, I want to take some time to share insight with this audience as a developer, as a company, and as an open source enthusiast.
There are two principal elements that make open source successful. The first is that it is licensed under OSS licenses that promote and support free distribution of the source with the binaries for people to use any way they want. When GPL (General Public License) was introduced in the 1990s, it was revolutionary—no charge, source included, and no restriction on use. That helped proliferate open source projects like Linux and allowed rapid innovation.
The other particularly essential element is the way open source software grows and develops. It happens through a community of people who are most often not in the same organization or geographic location. They come together because they believe in the solution or mission of the project. Because these people came from different development cultures but needed to work on common projects, they evolved norms for working together, such as how they communicate with each other, how decisions are made, and how to review new submissions. This codification of how disparate teams work without being in the same organization is unique and powerful. This type of development is known as "collaborative development."
Not all communities are effective, but the ones who figure out how to work together often have some common elements:
* Governance: They work out how the project will govern itself—decisions, roles, reviews, meetings, mission, budgets, organization structures, etc.
* Communication: They figure out how to work with people across time zones, across cultures, and organizations. For example, documenting decisions on a mailing list vs. live discussions. Providing people with 24 to 48 hours to review and respond to a question or decision is another good practice established to allow people in different zones and different work situations to collaborate.
* Common tools: Review and communication are imperative to development. Tools such as GitLab and GitHub build in collaborative practices to enable working across teams.
* Architecture: Projects are often architected for maximum engagement into components, API (Application Programming Interface), sub-systems so that not everyone needs to know everything, or they dont change the whole project when they make changes.
Both in response to digital challenges as well as changing customer expectations, enterprises outside of the tech vendor space, in particular, have been transforming how they build products and services as well as how they engage with their customers. And with the 2020 COVID-19 pandemic, many companies and organizations have gone virtual and fast-tracked their digital transformation plans to meet changing customer and market needs. And some accelerated their plans to capture new opportunities and support changes in how customers consumed their services. Teams that relied on physical proximity, hallway conversations, and other elements of development were faced with a need to change how they worked. Many of them realized that they could turn to the collaborative development model of open source for examples of how to work remotely and effectively.
Even before the COVID-19 pandemic, because of early digital transformation plans, companies had already begun adopting and working with open source and had realized the benefits of open innovation. The need to go faster, reduce costs, breakdown silos across the company, and reuse vs. reinvent has created a spur to do more collaborative development or open source-style community development inside the company walls.
The benefits of collaborative development can be applied in many ways:
* Collaboration among remote and geographically distributed organizations
* Creating a more open and collaborative culture inside a company
* Creating communities around common interests and common problems
The traditional way companies develop software inside companies is quite different from the open source collaborative model. Because of how budgets, organization structures, and incentives work, teams work in silos, are top-driven, and have no incentive to share and collaborate across the organization. Teams often report to the same organization, resulting in low documentation of decisions and low leverage of experts across the company.
Many organizations have been experimenting with collaborative development for some time. At Comcast, for example, teams called it enterprise source. But then the term "inner source" was created by Tim OReilly, founder, CEO, and publisher at OReilly publishing in 2001. (This [interview][2] with Tim is a remarkable story of how he came to coin this term). He talks about how the modularity of code and the access to source was a huge driver for collaboration, even more than the license itself. He calls it the "Architecture of Participation." Soon after, in 2015, Danese Cooper, who was running the OSPO (Open Source Program Office) at PayPal at that time, [introduced this term][3] at OSCON. She also shared what PayPal had been doing inside the company to break down silos and to create collaboration. The [InnerSource Commons][4] non-profit foundation was also established to allow people to collaborate on their experiences, patterns, and best practices. Here is a more formal definition of inner source:
> "Inner source is an adaptation of open source practices to code that remains proprietary and can be seen only within a single organization, or a small set of collaborating organizations. Thus, inner source is a historical development drawing on the open source movement along with other trends in software."
>
> —From [_Adopting InnerSource_][5], OReilly Publications
The biggest similarities between open source and inner source involve the collaborative development model. Working across teams inside an organization on common source code is a culture change for a traditional enterprise. Both versions of it need sponsorship and support from the top to thrive inside an organization.
The biggest differences are what motivates one to start an inner source project over an open source project. The often-repeated wisdom of open source communities is that people get into it because they have an "itch to scratch." Often, trying to solve a technical issue is the reason that they start a new project. With inner source, there may be more of an organization-wide reason to start opening their code and collaborating with other teams. One main reason is to enable another team to work more effectively with the platform or to reduce a duplicate effort. Some organizations have chosen a default approach of opening all repositories for anyone in the company to see and use or collaborate on. One huge driver has been to stage it as an inner source project before fully open sourcing it. This allows the team to hone a good collaboration strategy and practice before open sourcing.
I like the model that PayPal used—having inner source and open source be a part of the same organization. There are shared practices, skills, and tools that can be used across the two. At Comcast, both practices live in the Open Source Program Office. The inner source team has built a guild with members of architecture, security, and leadership to develop the practice and governance of our inner source projects. You can listen to Comcast Open Source Program Manager and InnerSource leader Brittany Istenes [talk][6] to hear more about what we did with the guild and scaling inner source back from the InnerSource Commons Fall 2020 Summit.
While some people criticize the inner source movement and say that it has distracted from the open source movement, it has actually accelerated open source collaborative practices inside organizations. While most companies use open source, few were deeply engaged in communities or understood how open collaboration works. The fact that the collaborative development model can be used inside a company to do product or organizational work has led to a deeper understanding and better development practices at Comcast. I see a natural growth from this to more contributions and more engagement with open source communities as teams feel more confident in engaging through their inner source work.
No matter what you call it—inner source, enterprise source, collaborative development—more collaboration inside the company is a particularly good thing. Better development practices, documentation, onboarding, and mentoring are often direct results. If you are interested in more information, check out [innersourcecommons.org][7] for great talks from several companies practicing inner source, including Comcast. I believe that inner source is the next phase of open source development.
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/11/inner-source
作者:[Nithya Ruff][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://opensource.com/users/nithyaruff
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/whiteboard-brainstorming-brainmapping-design-thinking-postits-kanban.png?itok=Is2Tg1Jk (Brainstorming with post-it notes on a whiteboard)
[2]: https://www.youtube.com/watch?v=2HR0D8_tKoA&t=573s
[3]: https://www.youtube.com/watch?v=r4QU1WJn9f8
[4]: https://innersourcecommons.org/
[5]: https://www.oreilly.com/library/view/adopting-innersource/9781492041863/ch01.html
[6]: https://www.youtube.com/watch?v=RenQ8B7aX84
[7]: http://innersourcecommons.org

View File

@ -1,181 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Getting started with Emacs)
[#]: via: (https://opensource.com/article/20/3/getting-started-emacs)
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
Getting started with Emacs
======
10 tips for diving into the world of this useful group of open source
text editors.
![Computer keyboard typing][1]
Many people say they want to learn [Emacs][2], but many of them shy away after the briefest encounter. It's not because Emacs is bad or even that complex. The problem, I believe, is that people don't actually want to learn Emacs; they want to be comfortable with Emacs traditions. They want to understand the arcane keyboard shortcuts and unfamiliar terminology. They want to use Emacs as they believe it's "meant to be used."
I sympathize with this because that's how I felt about Emacs. I thought that all true Emacs users only ran it inside a terminal, and never used arrow keys or menus, much less a mouse. That's a great way to discourage yourself from getting started with Emacs. There are enough unique .emacs config files out there to prove that if there's one common strain among Emacs users, it's that everyone uses Emacs differently.
Learning Emacs is easy. It's loving Emacs that's hard. To love Emacs, you have to discover the features it has that you've been looking for, sometimes without knowing you've been missing them. And that takes experience.
The only way to get that experience is to start at the beginning—by actively using Emacs. Here are ten tips to help you figure out what works best for you.
### Start with the GUI
One of the greatest things about Emacs (and its friendly competitor, [Vim][3], too) is that it can be run in a terminal, which is useful when you SSH into a server, but not very significant on computers built within the last 15 years or so. The GUI version of Emacs can be run on extremely [low-powered devices][4], and it has lots of pragmatic features that both novice and experienced users can appreciate.
For example, if you don't know how to copy a word with just keyboard shortcuts in Emacs, the Edit menu's Copy, Cut, and Paste selections provide the path of least resistance. There's no reason to punish yourself for choosing Emacs. Use its menus, use your mouse to select regions and click in-buffer buttons, and don't let unfamiliarity stand in your way of being productive.
![Emacs slackware][5]
These features are built into Emacs because users use them. You should use them when you need them and work your way up to the obscure commands you think you might need when you eventually use Emacs over SSH on a VT100 terminal with no Alt or arrow keys.
### Get used to the terminology
Emacs has special terms for its UI elements. The evolution of personal computing didn't build upon the same terms, so many are relatively foreign to the modern computer user, and others are the same but have different meanings. Here are some of the most common terms:
* Frame: In Emacs, the frame is what modern computing calls a "window."
* Buffer: A buffer is a communication channel for Emacs. It may serve as a command-line for an Emacs process, or a shell, or just the contents of a file.
* Window: A window is your view into a buffer.
* Mini-buffer: The primary command-line, located at the bottom of the Emacs window.
![Emacs tutorial map][6]
### Making sense of Emacs modifier keys
On a PC keyboard, the Ctrl key is referred to as C, and the Alt key is referred to as M. These aren't the C and M keys, and because they're always paired with an accompanying letter or symbol key, they're easy to recognize in the documentation.
For example, C-x means Ctrl+X in modern keyboard notation, and M-x is Alt+X. You press the keys together just as you do when you're cutting text from any application.
There's another level of keyboard shortcuts, though, quite unlike anything on modern computers. Sometimes, a keyboard shortcut isn't just one key combo and instead consists of a series of key presses.
For instance, C-x C-f means to press Ctrl+X as usual, and then Ctrl+C as usual.
Sometimes, a keyboard shortcut has a mixture of key types. The combo C-x 3 means to press Ctrl+X as usual, and then the number 3 key.
The way Emacs can do these fancy power combos is because certain keys put Emacs into a special command mode. If you press C-X (that's Ctrl+X), you're telling Emacs to enter an idle state, waiting for a second key or keyboard shortcut.
Emacs documentation, both official and unofficial, is full of keyboard shortcuts. Practice mentally translating C to Ctrl and M to Alt, and all those docs will make a lot more sense to you.
### Alternate shortcuts for cut, copy, and paste
Canonically, copying text is performed with a series of keyboard shortcuts that depend on how you want to copy or cut.
For instance, you can cut a whole word with M-d (Emacs lingo for Alt+d), or a whole line with C-k (Ctrl+K), or a highlighted region with M-m (Alt+M). You can get used to that if you want, but if you like Ctrl+C and Ctrl+X and Ctrl-V, then you can use those instead.
Enabling modern cut-copy-paste requires activating a feature called CUA (Common User Access). To activate CUA, click on the Options menu and select Use CUA Keys. With this enabled, C-c copies highlighted text, C-x cuts highlighted text, and C-v pastes text. This mode is only actually active when you've selected text, so you can still learn the usual C-x and C-c bindings that Emacs normally uses.
### It's OK to share
Emacs is an application and has no awareness of your feelings or loyalty towards it. If you want to use Emacs only for tasks that "feel" right for Emacs, and different editor (like Vim) for other tasks, you can do that.
Your interactions with an application influence how you work, so if the pattern of keypresses required in Emacs doesn't agree with a specific task, then don't force yourself to use Emacs for that task. Emacs is just one of many open source tools available to you, and there's no reason to limit yourself to just one tool.
### Explore new functions
Most of what Emacs does is an elisp function that can be invoked from a menu selection, keyboard shortcut, or in some cases, a specific event. All functions can be executed from the mini-buffer (the command-line at the bottom of the Emacs frame). You could, in theory, even navigate your cursor by typing in functions like **forward-word** and **backward-word** and **next-line** and **previous-line**, and so on. It would be unbearably inefficient, but that's the kind of direct access to the code you're running. In a way, Emacs is its own API.
You can find out about new functions by reading about Emacs on community blogs, or you can take a more direct approach and use the describe-function function. To get help on any function, press M-x (that's Alt+X) and then type describe-function, and then press Return or Enter. You are prompted for a function name, and then shown a description of that function.
You can get a list of all available functions by typing M-x (Alt+X), followed by ?.
You can also get pop-up descriptions of functions as you type them by pressing M-x and then typing **auto-complete-mode**, and then pressing Return or Enter. With this mode active, as you type any Emacs function into your document, you're offered auto-completion options, along with a description of the function.
![Emacs function][7]
When you find a useful function and use it, Emacs tells you the keyboard binding for it, if one is set. If one doesn't exist, you can assign one yourself by opening your $HOME/.emacs configuration file and entering a keyboard shortcut assignment. The syntax is global-set-key, followed by the keyboard shortcut you want to use, followed by the function you want to invoke.
For example, to assign the screenwriter-slugline function to a keyboard binding:
```
`(global-set-key (kbd “C-c s”) 'screenwriter-slugline)`
```
Reload your configuration file, and the keyboard shortcut is available to you:
```
`M-x load-file ~/.emacs`
```
### Panic button
As you use Emacs and try new functions, you're bound to start invoking something you didn't mean to invoke. The universal panic button in Emacs is C-g (that's Ctrl+G).
I remember this by associating G with GNU, and I imagine I'm calling upon GNU to rescue me from a poor decision, but feel free to make up your own mnemonic.
If you press C-g a few times, the Emacs mini-buffer returns to a latent state, pop-up windows are hidden, and you're back to the safety of a plain old boring text editor.
### Ignore the keyboard shortcuts
There are too many potential keyboard shortcuts to summarize them all here, much less for you ever to hope to memorize. That's by design. Emacs is meant to be customized, and when people write plugins for Emacs, they get to define their own special keyboard shortcuts.
The idea isn't to memorize all shortcuts right away. Your goal, instead, is to get comfortable using Emacs. The more comfortable you become in Emacs, the more you'll get tired of resorting to the menu bar all the time, and you'll start to memorize the combos important to you.
Everyone has their own favorite shortcuts based on what they typically do in Emacs. Someone who spends all day writing code in Emacs may know all the keyboard shortcuts for running a debugger or for launching language-specific modes, but know nothing about Org-mode or Artist-mode. It's natural, and it's fine.
### Practice Emacs when you use Bash
One advantage to knowing Emacs keyboard shortcuts is that many of them also apply in Bash:
* C-a—go to the beginning of a line
* C-e—go to the end of a line
* C-k—cut the whole line
* M-f—go forward a word
* M-b—go back a word
* M-d—cut a word
* C-y—yank back (paste) the most recently cut content
* M-Shift-U—capitalize a word
* C-t—swap two characters (for example, sl becomes ls)
There are many more examples, and it an make your interactions with your Bash terminal faster than you ever imagined.
### Packages
Emacs has a built-in package manager to help you discover new plugins. Its package manager contains modes to help you edit specific types of text (for instance, if you edit JSON files frequently, you might try ejson-mode), embedded applications, themes, spellchecking options, linters, and more. This is where Emacs has the potential to become crucial to your daily computing; once you find a great Emacs package, you may not be able to live without it.
![Emacs emoji][8]
You can browse packages by pressing M-x (that's Alt+X) and then typing **package-list-packages** command and then pressing Return or Enter. The package manager updates its cache each time you launch it, so be patient the first time you use it while it downloads a list of available packages. Once loaded, you can navigate with your keyboard or mouse (remember, Emacs is a GUI application). Each package name is a button, so either move your cursor over it and press Return or just click it with your mouse. You can read about the package in the new window that appears in your Emacs frame, and then install it with the Install button.
Some packages need special configuration, which is sometimes listed in its description, but other times require you to visit the package's home page to read more about it. For example, the auto-complete package ac-emoji installs easily but requires you to have a symbol font defined. It works either way, but you only see the corresponding emoji if you have the font installed, and you might not know that unless you visit its homepage.
### Tetris
Emacs has games, believe it or not. There's Sudoku, quizzes, minesweeper, a just-for-fun psychotherapist, and even Tetris. These aren't particularly useful, but interacting with Emacs on any level is great practice, and games are a great way to maximize your time spent in Emacs.
![Emacs tetris][9]
Tetris is also how I was introduced to Emacs in the first place, so of all versions of the game, it's the Emacs version that's truly my favorite.
### Using Emacs
GNU Emacs is popular because it's impossibly flexible and highly extensible. People get so accustomed to Emacs keyboard shortcuts that they habitually try to use them in all other applications, and they build applications into Emacs, so they never have to leave in the first place. If you want Emacs to play an important role in your computing life, the ultimate key is to embrace the unknown and start using Emacs. Stumble through it until you've discovered how to make it work for you, and then settle in for 40 years of comfort.
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/3/getting-started-emacs
作者:[Seth Kenlon][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://opensource.com/users/seth
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/keyboaord_enter_writing_documentation.jpg?itok=kKrnXc5h (Computer keyboard typing)
[2]: https://opensource.com/downloads/emacs-cheat-sheet
[3]: https://opensource.com/downloads/cheat-sheet-vim
[4]: https://opensource.com/article/17/2/pocketchip-or-pi
[5]: https://opensource.com/sites/default/files/uploads/emacs-slackware.jpg (Emacs slackware)
[6]: https://opensource.com/sites/default/files/uploads/emacs-tutorial-map.png (Emacs tutorial map)
[7]: https://opensource.com/sites/default/files/uploads/emacs-function.jpg (Emacs function)
[8]: https://opensource.com/sites/default/files/uploads/emacs-emoji_0.jpg (Emacs emoji)
[9]: https://opensource.com/sites/default/files/uploads/emacs-tetris.jpg (Emacs tetris)

View File

@ -0,0 +1,223 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Getting started with Fedora CoreOS)
[#]: via: (https://fedoramagazine.org/getting-started-with-fedora-coreos/)
[#]: author: (Clément Verna https://fedoramagazine.org/author/cverna/)
Getting started with Fedora CoreOS
======
![Getting started with Fedora CoreOS][1]
Photo by [Paweł Czerwiński][2] on [Unsplash][3]
This has been called the age of DevOps, and operating systems seem to be getting a little bit less attention than tools are. However, this doesnt mean that there has been no innovation in operating systems. [Edit: The diversity of offerings from the plethora of distributions based on the Linux kernel is a fine example of this.] [Fedora CoreOS][4] has a specific philosophy of what an operating system should be in this age of DevOps.
### Fedora CoreOS philosophy
Fedora CoreOS (FCOS) came from the merging of CoreOS Container Linux and Fedora Atomic Host. It is a minimal and monolithic OS focused on running containerized applications. Security being a first class citizen, FCOS provides automatic updates and comes with SELinux hardening.
For automatic updates to work well they need to be very robust. The goal being that servers running FCOS wont break after an update. This is achieved by using different release streams (stable, testing and next). Each stream is released every 2 weeks and content is promoted from one stream to the other (next -> testing -> stable). That way updates landing in the stable stream have had the opportunity to be tested over a long period of time.
### Getting Started
For this example lets use the stable stream and a QEMU base image that we can run as a virtual machine. You can use [coreos-installer][5] to download that image.
From your (Workstation) terminal, run the following commands after updating the link to the image. [Edit: On Silverblue the container based coreos tools are the simplest method to try. Instructions can be found at <https://docs.fedoraproject.org/en-US/fedora-coreos/tutorial-setup/> , in particular “Setup with Podman or Docker”.]
```
$ sudo dnf install coreos-installer
$ coreos-installer download --image-url https://builds.coreos.fedoraproject.org/prod/streams/stable/builds/32.20200907.3.0/x86_64/fedora-coreos-32.20200907.3.0-qemu.x86_64.qcow2.xz
$ xz -d fedora-coreos-32.20200907.3.0-qemu.x86_64.qcow2.xz
$ ls
fedora-coreos-32.20200907.3.0-qemu.x86_64.qcow2
```
#### Create a configuration
To customize a FCOS system, you need to provide a configuration file that will be used by [Ignition][6] to provision the system. You may use this file to configure things like creating a user, adding a trusted SSH key, enabling systemd services, and more.
The following configuration creates a _core_ user and adds an SSH key to the authorized_keys file. It is also creating a systemd service that uses [podman][7] to run a simple hello world container.
```
version: "1.0.0"
variant: fcos
passwd:
users:
- name: core
ssh_authorized_keys:
- ssh-ed25519 my_public_ssh_key_hash fcos_key
systemd:
units:
-
contents: |
[Unit]
Description=Run a hello world web service
After=network-online.target
Wants=network-online.target
[Service]
ExecStart=/bin/podman run --pull=always --name=hello --net=host -p 8080:8080 quay.io/cverna/hello
ExecStop=/bin/podman rm -f hello
[Install]
WantedBy=multi-user.target
enabled: true
name: hello.service
```
After adding your SSH key in the configuration save it as _config.yaml_. Next use the Fedora CoreOS Config Transpiler (fcct) tool to convert this YAML configuration into a valid Ignition configuration (JSON format).
Install _fcct_ directly from Fedoras repositories or get the binary from [GitHub][8].
```
$ sudo dnf install fcct
$ fcct -output config.ign config.yaml
```
#### Install and run Fedora CoreOS
To run the image, you can use the libvirt stack. To install it on a Fedora system using the dnf package manager
```
$ sudo dnf install @virtualization
```
Now lets create and run a Fedora CoreOS virtual machine
```
$ chcon --verbose unconfined_u:object_r:svirt_home_t:s0 config.ign
$ virt-install --name=fcos \
--vcpus=2 \
--ram=2048 \
--import \
--network=bridge=virbr0 \
--graphics=none \
--qemu-commandline="-fw_cfg name=opt/com.coreos/config,file=${PWD}/config.ign" \
--disk=size=20,backing_store=${PWD}/fedora-coreos-32.20200907.3.0-qemu.x86_64.qcow2
```
Once the installation is successful, some information is displayed and a login prompt is provided.
```
Fedora CoreOS 32.20200907.3.0
Kernel 5.8.10-200.fc32.x86_64 on an x86_64 (ttyS0)
SSH host key: SHA256:BJYN7AQZrwKZ7ZF8fWSI9YRhI++KMyeJeDVOE6rQ27U (ED25519)
SSH host key: SHA256:W3wfZp7EGkLuM3z4cy1ZJSMFLntYyW1kqAqKkxyuZrE (ECDSA)
SSH host key: SHA256:gb7/4Qo5aYhEjgoDZbrm8t1D0msgGYsQ0xhW5BAuZz0 (RSA)
ens2: 192.168.122.237 fe80::5054:ff:fef7:1a73
Ignition: user provided config was applied
Ignition: wrote ssh authorized keys file for user: core
```
The Ignition configuration file did not provide any password for the _core_ user, therefore it is not possible to login directly via the console. (Though, it is possible to configure a password for users via Ignition configuration.)
Use Ctrl + ] key combination to exit the virtual machines console. Then check if the hello.service is running.
```
$ curl http://192.168.122.237:8080
Hello from Fedora CoreOS!
```
Using the preconfigured SSH key, you can also access the VM and inspect the services running on it.
```
$ ssh core@192.168.122.237
$ systemctl status hello
● hello.service - Run a hello world web service
Loaded: loaded (/etc/systemd/system/hello.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2020-10-28 10:10:26 UTC; 42s ago
```
#### zincati, rpm-ostree and automatic updates
The zincati service drives rpm-ostreed with automatic updates.
Check which version of Fedora CoreOS is currently running on the VM, and check if Zincati has found an update.
```
$ ssh core@192.168.122.237
$ rpm-ostree status
State: idle
Deployments:
● ostree://fedora:fedora/x86_64/coreos/stable
Version: 32.20200907.3.0 (2020-09-23T08:16:31Z)
Commit: b53de8b03134c5e6b683b5ea471888e9e1b193781794f01b9ed5865b57f35d57
GPGSignature: Valid signature by 97A1AE57C3A2372CCA3A4ABA6C13026D12C944D0
$ systemctl status zincati
● zincati.service - Zincati Update Agent
Loaded: loaded (/usr/lib/systemd/system/zincati.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2020-10-28 13:36:23 UTC; 7s ago
Oct 28 13:36:24 cosa-devsh zincati[1013]: [INFO ] initialization complete, auto-updates logic enabled
Oct 28 13:36:25 cosa-devsh zincati[1013]: [INFO ] target release '32.20201004.3.0' selected, proceeding to stage it
... zincati reboot ...
```
After the restart, lets remote login once more to check the new version of Fedora CoreOS.
```
$ ssh core@192.168.122.237
$ rpm-ostree status
State: idle
Deployments:
● ostree://fedora:fedora/x86_64/coreos/stable
Version: 32.20201004.3.0 (2020-10-19T17:12:33Z)
Commit: 64bb377ae7e6949c26cfe819f3f0bd517596d461e437f2f6e9f1f3c24376fd30
GPGSignature: Valid signature by 97A1AE57C3A2372CCA3A4ABA6C13026D12C944D0
ostree://fedora:fedora/x86_64/coreos/stable
Version: 32.20200907.3.0 (2020-09-23T08:16:31Z)
Commit: b53de8b03134c5e6b683b5ea471888e9e1b193781794f01b9ed5865b57f35d57
GPGSignature: Valid signature by 97A1AE57C3A2372CCA3A4ABA6C13026D12C944D0
```
_rpm-ostree status_ now shows 2 versions of Fedora CoreOS, the one that came in the QEMU image, and the latest one received from the update. By having these 2 versions available, it is possible to rollback to the previous version using the _rpm-ostree rollback_ command.
Finally, you can make sure that the hello service is still running and serving content.
```
$ curl http://192.168.122.237:8080
Hello from Fedora CoreOS!
```
More information: [Fedora CoreOS updates][9]
#### Deleting the Virtual Machine
To clean up afterwards, the following commands will delete the VM and associated storage.
```
$ virsh destroy fcos
$ virsh undefine --remove-all-storage fcos
```
### Conclusion
Fedora CoreOS provides a solid and secure operating system tailored to run applications in containers. It excels in a DevOps environment which encourages the hosts to be provisioned using declarative configuration files. Automatic updates and the ability to rollback to a previous version of the OS, bring a peace of mind during the operation of a service.
Learn more about Fedora CoreOS by following the tutorials available in the projects [documentation][10].
--------------------------------------------------------------------------------
via: https://fedoramagazine.org/getting-started-with-fedora-coreos/
作者:[Clément Verna][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://fedoramagazine.org/author/cverna/
[b]: https://github.com/lujun9972
[1]: https://fedoramagazine.org/wp-content/uploads/2020/11/fcos-gettingstarted-1-816x345.jpg
[2]: https://unsplash.com/@pawel_czerwinski?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText
[3]: https://unsplash.com/s/photos/core?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText
[4]: https://getfedora.org/coreos/
[5]: https://github.com/coreos/coreos-installer/releases
[6]: https://github.com/coreos/ignition
[7]: https://podman.io/
[8]: https://github.com/coreos/fcct/releases
[9]: https://docs.fedoraproject.org/en-US/fedora-coreos/auto-updates/
[10]: https://docs.fedoraproject.org/en-US/fedora-coreos/tutorials/

View File

@ -0,0 +1,146 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (How to choose a wireless protocol for home automation)
[#]: via: (https://opensource.com/article/20/11/wireless-protocol-home-automation)
[#]: author: (Steve Ovens https://opensource.com/users/stratusss)
How to choose a wireless protocol for home automation
======
Which of the three dominant wireless protocols used in home
automation—WiFi, Z-Wave, and Zigbee—is right for you? Consider the
options in part three of this series.
![Digital images of a computer desktop][1]
In the second article in this series, I talked about [local control vs. cloud connectivity][2] and some things to consider for your home automation setup.
In this third article, I will discuss the underlying technology for connecting devices to [Home Assistant][3], including the dominant protocols that smart devices use to communicate and some things to think about before purchasing smart devices.
### Connecting devices to Home Assistant
Many different devices work with Home Assistant. Some connect through a cloud service, and others work by communicating with a central unit, such as a [SmartThings Hub][4], that Home Assistant communicates with. And still others have a facility to communicate over your local network.
For a device to be truly useful, one of its key features must be wireless connectivity. There are currently three dominant wireless protocols that smart devices use: WiFi, Z-Wave, and Zigbee. I'll do a quick breakdown of each including their pros and cons.
**A note about wireless spectra:** Spectra are measured in hertz (Hz). A gigahertz (GHz) is 1 billion Hz. In general, the larger the number of Hz, the more data can be transmitted and the faster the connection. However, higher frequencies are more susceptible to interference and do not travel very well through solid objects. Lower frequencies can travel further and pass through solid objects more readily, but the trade-off is they cannot send much data.
### WiFi
[WiFi][5] is the most widely known of the three standards. These devices are the easiest to get up and running if you are starting from scratch. This is because almost everyone interested in home automation already has a WiFi router or an access point. In fact, in most countries in the western world, WiFi is considered almost on the same level as running water; if you go to a hotel, you expect a clean, temperature-controlled room with a WiFi password provided at check-in.
Therefore, Internet of Things (IoT) devices that use the WiFi protocol require no additional hardware to get started. Plug in the new device, launch a vendor-provided application or a web browser, enter your credentials, and you're done.
It's important to note that almost all moderate- to low-priced IoT devices use the 2.4GHz wireless spectrum. Why does this matter? Well, 2.4GHz has been around so long that virtually all devices—from cordless phones to smart bulbs—use this spectrum. In most countries, there are generally only about a dozen channels that off-the-shelf devices can broadcast and receive on. Like overloading a cell tower when too many users attempt to make phone calls during an emergency, channels can become overcrowded and susceptible to outside interference.
While well-behaving smart devices use little-to-no bandwidth, if they struggle to send/receive messages due to overcrowding on the spectrum, your automation will have mixed results. A WiFi access point can only communicate with one client at a time. That means the more devices you have on WiFi, the greater the chance that someone on the network will have to wait their turn to communicate.
**Pros:**
* Ubiquitous
* Tend to be inexpensive
* Easy to set up
* Easy to extend the range
* Uses existing network
* Requires no hub
**Cons:**
* Can suffer from interference from neighboring devices or adjacent networks
* Uses the most populated 2.4GHz spectrum
* Your router limits the number of devices
* Uses more power, which means less or no battery-powered devices
* Has the potential to impact latency-sensitive activities like gaming over WiFi
* Most off-the-shelf products require an internet connection
### Z-Wave
[Z-Wave][6] is a closed wireless protocol controlled and maintained by a company named Zensys. Because it is controlled by a single entity, all devices are guaranteed to work together. There is one standard and one implementation. This means that you never have to worry about which device you buy from which manufacturer; they will always work.
Z-Wave operates in the 0.9GHz spectrum, which means it has the largest range of the popular protocols. A central hub is required to coordinate all the devices on a Z-Wave ecosystem. Z-Wave operates on a [mesh network][7] topology, which means that every device acts as a potential repeater for other devices. In theory, this allows a much greater coverage area. Z-Wave limits the number of "hops" to 4. That means that, in order for a signal to get from a device to a hub, it can only travel through four devices. This could be a positive or a negative, depending on your perspective. 
On the one hand, it reduces the ecosystem's maximum latency by preventing packets from traveling through a significant number of devices before reaching the destination. The more devices a signal must go through, the longer it can take for devices to become responsive.
On the other hand, it means that you need to be more strategic about providing a good path from your network's extremities back to the hub. Remember, the lower frequency that enables greater distance also limits the speed and amount of data that can be transferred. This is currently not an issue, but no one knows what size messages future smart devices will want to send.
**Pros:**
* Z-Wave compatibility guaranteed
* Form mesh network 
* Low powered and can be battery powered
* Mesh networks become more reliable with more devices
* Uses 0.9GHz and can transmit up to 100 meters
* Least likely of the three to have signal interference from solid objects or external sources
**Cons:**
* Closed protocol
* Costs the most
* Maximum of four hops in the mesh
* Can support up to 230 devices per network
* Uses 0.9GHz, which is the slowest of all protocols
### Zigbee
Unlike Z-Wave, [Zigbee][8] is an open standard. This can be a pro or a con, depending on your perspective. Because it is an open standard, manufacturers are free to alter the implementation to suit their products. To borrow an analogy from one of my favorite YouTube channels, [The Hook Up][9], Zigbee is like going through a restaurant drive-through. Having the same standard means you will always be able to speak to the restaurant and they will be able to hear you. However, if you speak a different language than the drive-through employee, you won't be able to understand each other. Both of you can speak and hear each other, but the meaning will be lost.
Similarly, the Zigbee standard allows all devices on a Zigbee network to "hear" each other, but different implementations mean they may not "understand" each other. Fortunately, more often than not, your Zigbee devices should be able to interoperate. However, there is a non-trivial chance that your devices will not be able to understand each other. When this happens, you may end up with multiple networks that could interfere with each other.
Like Z-Wave, Zigbee employs a mesh network topology but has no limit to the number of "hops" devices can use to communicate with the hub. This, combined with some tweaks to the standard, means that Zigbee theoretically can support more than 65,000 devices on a single network.
**Pros:**
* Open standard
* Form mesh network
* Low-powered and can be battery powered
* Can support over 65,000 devices
* Can communicate faster than Z-Wave
**Cons:**
* No guaranteed compatibility
* Can form separate mesh networks that interfere with each other
* Uses the oversaturated 2.4GHz spectrum
* Transmits only 10 to 30 meters
### Pick your protocol
Perhaps you already have some smart devices. Or maybe you are just starting to investigate your options. There is a lot to consider when you're buying devices. Rather than focusing on the lights, sensors, smart plugs, thermometers, and the like, it's perhaps more important to know which protocol (WiFi, Z-Wave, or Zigbee) you want to use.
Whew! I am finally done laying home automation groundwork. In the next article, I will show you how to start the initial installation and configuration of a Home Assistant virtual machine.
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/11/wireless-protocol-home-automation
作者:[Steve Ovens][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://opensource.com/users/stratusss
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_browser_web_desktop.png?itok=Bw8ykZMA (Digital images of a computer desktop)
[2]: https://opensource.com/article/20/11/cloud-vs-local-home-automation
[3]: https://opensource.com/article/20/11/home-assistant
[4]: https://www.smartthings.com/
[5]: https://en.wikipedia.org/wiki/Wi-Fi
[6]: https://www.z-wave.com/
[7]: https://en.wikipedia.org/wiki/Mesh_networking
[8]: https://zigbeealliance.org/
[9]: https://www.youtube.com/channel/UC2gyzKcHbYfqoXA5xbyGXtQ

View File

@ -0,0 +1,177 @@
[#]: collector: (lujun9972)
[#]: translator: (wxy)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Getting started with Emacs)
[#]: via: (https://opensource.com/article/20/3/getting-started-emacs)
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
10 个 Emacs 入门技巧
======
> 10 个技巧,让你深入这个有用的开源文本编辑器的世界。
!["电脑键盘打字"][1]
很多人都说想学 [Emacs][2],但很多人在短暂的接触后就退缩了。这并不是因为 Emacs 不好,甚至复杂。我相信,问题在于人们其实并不想学习 Emacs他们想习惯 Emacs 的传统。他们想了解那些神秘的键盘快捷键和不熟悉的术语。他们想按照他们认为的“使用目的”来使用 Emacs。
我很同情这一点,因为我对 Emacs 的感觉就是这样。我以为真正的 Emacs 用户都只会在终端里面运行,从来不用方向键和菜单,更不会用鼠标。这是个阻止自己开始使用 Emacs 的好办法。有足够多的独特的 `.emacs` 配置文件证明,如果说 Emacs 用户有一个共同的应变能力,那就是每个人使用 Emacs 的方式不同。
学习 Emacs 很容易。爱上 Emacs 才是最难的。要爱上 Emacs你必须发现它所拥有的功能而这些功能是你一直在寻找的有时你并不知道你已经错过了它们。而这需要经验。
获得这种经验的唯一方法就是从一开始就积极使用 Emacs。这里有十个小贴士可以帮助你找出最适合你的方法。
### 从 GUI 开始
Emacs以及它的友好竞争者 [Vim][3])最伟大的事情之一是它可以在终端中运行,这在你 SSH 进入服务器时很有用,但在过去 15 年左右制造的计算机上意义不大。Emacs 的 GUI 版本可以在极度[低功耗的设备][4]上运行,它有很多实用的功能,无论是新手还是有经验的用户都可以使用它。
例如,如果你不知道如何在 Emacs 中只用键盘快捷键复制一个单词,编辑菜单的复制、剪切和粘贴选择提供了最轻松的路径。没有理由因为选择了 Emacs 而惩罚自己。使用它的菜单,用鼠标选择区域,点击缓冲区内的按钮,不要让陌生感阻碍你的工作效率。
![Emacs slackware][5]
这些功能被内置到 Emacs 中,是因为用户使用它们。你应该在你需要的时候使用它们,而当你最终在 VT100 终端上通过 SSH 使用 Emacs没有 `Alt` 或方向键的时候,你就应该使用这些晦涩的命令。
### 习惯术语
Emacs 的 UI 元素有特殊的术语。个人计算的发展并不是建立在相同的术语上,所以很多术语对现代计算机用户来说比较陌生,还有一些术语虽然相同,但含义不同。下面是一些最常见的术语。
* <ruby>框架<rt>Frame</rt></ruby>。在 Emacs 中,框架就是现代计算机所说的“窗口”。
* <ruby>缓冲区<rt>Buffer</rt></ruby>:缓冲区是 Emacs 的一个通信通道。它可以作为 Emacs 进程的命令行,也可以作为 shell或者只是一个文件的内容。
* <ruby>窗口<rt>Window</rt></ruby>:一个窗口是你进入一个缓冲区的视角。
* <ruby>迷你缓冲区<rt>Mini-buffer</rt></ruby>。主要的命令行,位于 Emacs 窗口的底部。
![Emacs tutorial map][6]
### 让 Emacs 的修饰键变得更有意义
在 PC 键盘上,`Ctrl` 键被称为 `C``Alt` 键被称为 `M`,这些键并不是 `C``M` 键,由于它们总是与相应的字母或符号键配对,所以在文档中很容易识别。
例如,`C-x` 在现代键盘符号中的意思是 `Ctrl+X``M-x` 是 `Alt+X`。就像你从任何应用程序中剪切文本时一样,同时按下这两个键。
不过,还有另一个层次的键盘快捷键,与现代电脑上的任何东西都完全不同。有时,键盘快捷键并不只是一个键组合,而是由一系列的按键组成。
例如,`C-x C-f` 的意思是像往常一样按 `Ctrl+X`,然后再按 `Ctrl+C`
有时,一个键盘快捷键有混合的键型。组合键 `C-x 3` 意味着像往常一样按 `Ctrl+X`,然后按数字 `3` 键。
Emacs 之所以能做到这些花哨的强力组合,是因为某些键会让 Emacs 进入一种特殊的命令模式。如果你按 `C-X`(也就是 `Ctrl+X`),就是告诉 `Emacs` 进入空闲状态,等待第二个键或键盘快捷键。
Emacs 的文档,无论是官方的还是非官方的,都有很多键盘快捷键。在心里练习把 `C` 键翻译成 `Ctrl` 键,`M` 键翻译成 `Alt` 键,那么这些文档对你来说都会变得更有意义。
### 剪切、复制和粘贴的备用快捷方式
从规范上,复制文本是通过一系列的键盘快捷键进行的,这些快捷键取决于你想要复制或剪切的方式。
例如,你可以用 `M-d``Alt+d` 的 Emacs 行话)剪切一整个单词,或者用`C-k``Ctrl+K`)剪切一整行,或者用 `M-m``Alt+M`)剪切一个高亮区域。如果你想的话,你可以习惯这样,但如果你喜欢 `Ctrl+C``Ctrl+X``Ctrl-V`,那么你可以用这些来代替。
启用现代的剪切-复制-粘贴需要激活一个名为 CUA<ruby>通用用户访问<rt>Common User Access</rt></ruby>)的功能。要激活 CUA请单击“选项”菜单并选择“使用 CUA 键”。启用后,`C-c` 复制高亮显示的文本,`C-x` 剪切高亮显示的文本,`C-v` 粘贴文本。这个模式只有在你选择了文本之后才会实际激活,所以你仍然可以学习 Emacs 通常使用的 `C-x``C-c` 绑定。
### 用哪个都好
Emacs 是一个应用程序,它不会意识到你对它的感情或忠诚度。如果你想只用 Emacs 来完成那些“感觉”适合 Emacs 的任务,而用不同的编辑器(比如 Vim来完成其他任务你可以这样做。
你与一个应用程序的交互会影响你的工作方式,所以如果 Emacs 中所需要的按键模式与特定任务不一致,那么就不要强迫自己使用 Emacs 来完成该任务。Emacs 只是众多可供你使用的开源工具之一,没有理由让自己只限于一种工具。
### 探索新功能
Emacs 所做的大部分工作都是一个 elisp 函数它可以从菜单选择、键盘快捷键或者在某些情况下从特定事件中调用。所有的函数都可以从迷你缓冲区Emacs 框架底部的命令行)执行。理论上,你甚至可以通过键入 `forward-word``backward-word` 以及 `next-line``previous-line` 等函数来导航光标。这肯定是无比低效的但这就是一种直接访问你运行的代码的方式。在某种程度上Emacs 就是自己的 API。
你可以通过在社区博客上阅读有关 Emacs 的资料来了解新函数,或者你可以采取更直接的方法,使用描述函数(`describe-function`)。要获得任何函数的帮助,按 `M-x`(也就是 `Alt+X`),然后输入 `describe-function`,然后按回车键或回车键。系统会提示你输入一个函数名称,然后显示该函数的描述。
你可以通过键入`M-x`Alt+X`),然后键入 `?` 来获得所有可用函数的列表。
你也可以在输入函数时,通过按 `M-x` 键,然后输入 `auto-complete-mode`,再按回车键,获得弹出的函数描述。激活该模式后,当你在文档中键入任何 Emacs 函数时,都会向你提供自动补完选项,以及函数的描述。
![Emacs function][7]
当你找到一个有用的函数并使用它时Emacs 会告诉你它的键盘绑定,如果有的话。如果没有的话,你可以通过打开你的 `$HOME/.emacs` 配置文件并输入键盘快捷键来自己分配一个。语法是 ` global-set-key`,后面是你要使用的键盘快捷键,然后是你要调用的函数。
例如,要将 `screenwriter-slugline` 函数分配一个键盘绑定:
```
(global-set-key (kbd “C-c s”) 'screenwriter-slugline)
```
重新加载配置文件,键盘快捷键就可以使用了:
```
M-x load-file ~/.emacs
```
### 紧急按钮
当你使用 Emacs 并尝试新的函数时你一定会开始调用一些你并不想调用的东西。Emacs 中通用的紧急按钮是 `C-g`(就是 `Ctrl+G`)。
我通过将 G 与 GNU 联系起来来记住这一点,我想我是在呼吁 GNU 将我从一个错误的决定中拯救出来,但请随意编造你自己的记忆符号。
如果你按几下 `C-g`Emacs 的迷你缓冲区就会回到潜伏状态,弹出窗口被隐藏,你又回到了一个普通无聊的文本编辑器的安全状态。
### 忽略键盘快捷键
潜在的键盘快捷键太多在这里无法一一总结更不希望你能记住。这是设计好的。Emacs 的目的是为了定制,当人们为 Emacs 编写插件时,他们可以定义自己的特殊键盘快捷键。
我们的想法不是要马上记住所有的快捷键。相反,你的目标是让你在使用 Emacs 时感到舒适。你在 Emacs 中变得越舒服,你就越会厌倦总是求助于菜单栏,你就会开始记住对你重要的组合。
根据自己在 Emacs 中通常做的事情,每个人都有自己喜欢的快捷方式。一个整天用 Emacs 写代码的人可能知道运行调试器或启动特定语言模式的所有键盘快捷键,但对 Org 模式或 Artist 模式一无所知。这很自然,也很好。
### 当你使用 Bash 时就在练习 Emacs
了解 Emacs 键盘快捷键的一个好处是,其中许多快捷键也适用于 Bash。
* `C-a`:到行首
* `C-e`:到行尾
* `C-k`:剪切整行
* `M-f`:向前一个字
* `M-b`:向后一个字
* `M-d`:剪切一个字
* `C-y`:贴回(粘贴)最近剪切的内容
* `M-Shift-U`:大写一个词
* `C-t`:交换两个字符(例如,`sl` 变成 `ls`
还有更多的例子,它能让你与 Bash 终端的交互速度超乎你的想象。
### 包
Emacs 有一个内置的包管理器来帮助你发现新的插件。它的包管理器包含了帮助你编辑特定类型文本的模式(例如,如果你经常编辑 JSON 文件,你可以尝试使用 ejson 模式、嵌入应用程序、主题、拼写检查选项、linter 等。这就是 Emacs 有可能成为你日常计算的关键所在;一旦你找到一个优秀的 Emacs 包,你可能离不开它了。
![Emacs emoji][8]
你可以按 `M-x`(就是 `Alt+X`)键,然后输入 `package-list-packages` 命令再按回车键来浏览包。软件包管理器在每次启动时都会更新缓存所以第一次使用时要耐心等待它下载可用软件包的列表。一旦加载完毕你可以用键盘或鼠标进行导航记住Emacs 是一个 GUI 应用程序)。每一个软件包的名称都是一个按钮,所以你可以将光标移到它上面,然后按回车键,或者直接用鼠标点击它。你可以在 Emacs 框架中出现的新窗口中阅读有关软件包的信息然后用“Install”按钮安装它。
有些软件包需要特殊的配置,有时会在它的描述中列出,但有时需要你访问软件包的主页来阅读更多的信息。例如,自动完成包 `ac-emoji` 很容易安装,但需要你定义一个符号字体。无论哪种方式都可以使用,但你只有在安装了字体的情况下才能看到相应的表情符号,除非你访问它的主页,否则你可能不会知道。
### 俄罗斯方块
Emacs 有游戏,信不信由你。有数独、拼图、扫雷、一个好玩的心理治疗师,甚至还有俄罗斯方块。这些并不是特别有用,但在任何层面上与 Emacs 进行交互都是很好的练习,游戏是让你在 Emacs 中花费时间的好方法。
![Emacs tetris][9]。
俄罗斯方块也是我最初接触 Emacs 的方式所以在该游戏的所有版本中Emacs 版本才是我真正的最爱。
### 使用 Emacs
GNU Emacs 之所以受欢迎,是因为它的灵活性和高度可扩展性。人们习惯了 Emacs 的键盘快捷键,以至于他们习惯性地尝试在其他所有的应用程序中使用这些快捷键,他们将应用程序构建到 Emacs中所以他们永远不需要离开。如果你想让 Emacs 在你的计算生活中扮演重要角色,最终的关键是拥抱未知,开始使用 Emacs。磕磕绊绊地直到你发现如何让它为你工作然后安下心来享受 40 年的舒适生活。
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/3/getting-started-emacs
作者:[Seth Kenlon][a]
选题:[lujun9972][b]
译者:[wxy](https://github.com/wxy)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/seth
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/keyboaord_enter_writing_documentation.jpg?itok=kKrnXc5h (Computer keyboard typing)
[2]: https://opensource.com/downloads/emacs-cheat-sheet
[3]: https://opensource.com/downloads/cheat-sheet-vim
[4]: https://opensource.com/article/17/2/pocketchip-or-pi
[5]: https://opensource.com/sites/default/files/uploads/emacs-slackware.jpg (Emacs slackware)
[6]: https://opensource.com/sites/default/files/uploads/emacs-tutorial-map.png (Emacs tutorial map)
[7]: https://opensource.com/sites/default/files/uploads/emacs-function.jpg (Emacs function)
[8]: https://opensource.com/sites/default/files/uploads/emacs-emoji_0.jpg (Emacs emoji)
[9]: https://opensource.com/sites/default/files/uploads/emacs-tetris.jpg (Emacs tetris)