texts: How visually select files in Dired, in order to mark it at once?

texts:
In Dired, you can mark files each for each and do something with it.

I was wondering if there is any way to allow visual selection of files in Dired, so you can mark every line inside the visual region? Then there is no need to mark every file again and again. I found nothing in Emacs communities about this.


texts: Emacs lisp refactoring - add variable to surrounding let

texts:
Context

Call me an uncultured non-functional programmer (or call emacs-lisp and uncultured non-functional language), but when I code in elisp I tend to use the following pattern (Edit: As an alternative to let*)

(let (variable1 variable2)
    (setq variable1 (some-function))
    (setq variable2 (some-function))

I tend to find this more readable for my uncultured eyes.

Unfortunately, this means there is a lot of jumping back and forward between let and setq.

Question

Is there a way for me to quickly and easily insert a name into the surrounding let as shown:

(let ()
    ...
    CURSOR

becomes

 (let (variable)
    ...
    CURSOR stays still

Approaches considered

emr has some functions for emacs lisp refactoring. But not the one I want. The closest is extracting variables to let (together with assignment). I had a look at extending this but balked at the amount of code I would need to understand.

I had a brief look at erefactor, but relevant functionality wasn't there.

Code it myself This isn't hard, it's just I would prefer to use someone else's implementation should it exist. This feels like the sort of thing that should exist.

Edit: An example of why you might want to do this

Here is a function that sums numbers on the two previous lines and inserts the result.

(defun sum-lines ()
    (let (a b)
         (previous-line 2)
         (setq a (string-to-int (thing-at-point 'line))
         (forward-line 1)
         (setq b (string-to-int (thing-at-point 'line)))
         (forward-line 1)
         (insert (format "%S" (+ a b))))

Do you actaully want to write this as

(let* (
   (a (save-excursion (previous-line 2) (thing-at-point 'line))
   (b (save-excursion (previous-line 1) (thing-at-point 'line))

or

(let* (
   (a (progn (previous-line 2) (thing-at-point 'line))
   (b (progn (next-line 1) (thing-at-point 'line))

or

(defun line-at (n)
     (save-excursion
        (previous-line n)
      (string-to-int (thing-at-point 'line))

(insert (+ (line-at 2) (line-at 1)))


texts: I want to delete a remote branch. How can I do git push origin --delete my-branch in magit, to delete a remote branch?


texts: How do I add appointments to effort sum?

texts:
I have set up my appointments as below in my work.org.

* Work                                  :work:
** Client 1 Work
   <2020-06-03 Wed 09:00-10:00>
** Client 2 Work
   <2020-06-03 Wed 18:00-19:00>

And this is my org-agenda

Day-agenda (W23):
Wednesday   3 June 2020
               8:00...... ----------------
  work:        9:00-10:00 Client 1 Work                                                   :work::
              10:00...... ----------------
              10:14...... now - - - - - - - - - - - - - - - - - - - - - - - - -
              12:00...... ----------------
              14:00...... ----------------
              16:00...... ----------------
  work:       18:00-19:00 Client 2 Work                                                   :work::
              20:00...... ----------------

But when I go for my column view C-c C-x C-c in my agenda view, I notice that it my 1 hour appointments do not get added to my estimated effort or Actual effort.

I have setup the following in my .emacs

;; under custom-set-variables

'(org-agenda-time-grid
     (quote
      ((daily today require-timed remove-match)
       (800 1000 1200 1400 1600 1800 2000)
       "......" "----------------")))

'(org-columns-default-format
     "%25ITEM(Task) %TODO %TAGS %Effort(Estim){:}  %CLOCKSUM(ActTime)")

'(org-agenda-columns-add-appointments-to-effort-sum t)

I was hoping that setting org-agenda-columns-add-appointments-to-effort-sum as non-nil would help. The help shows the below

org-agenda-columns-add-appointments-to-effort-sum is a variable defined in ‘org-agenda.el’.
Its value is t
Original value was nil

Documentation:
Non-nil means the duration of an appointment will add to day effort.
The property to which appointment durations will be added is the one given
in the option ‘org-effort-property’.  If an appointment does not have
an end time, ‘org-agenda-default-appointment-duration’ will be used.  If that
is not set, an appointment without end time will not contribute to the time
estimate.

Quoting from the manual - https://orgmode.org/manual/Effort-Estimates.html

  If you switch to column view in the daily/weekly agenda, the effort
  column summarizes the estimated work effort for each day81, and you
  can use this to find space in your schedule. To get an overview of the
  entire part of the day that is committed, you can set the option
  org-agenda-columns-add-appointments-to-effort-sum. The appointments on
  a day that take place over a specified time interval are then also
  added to the load estimate of the day.

My requirement is that my appointments get added up in some way to my column view in agenda mode, so that I know how much time (effort) is already allocated and thus will give me an idea how much more time I can allocate for myself during the day.

Org mode - 9.3.6
Emacs - 26.3


texts: Org Export Latex: Defining Custom Classes for a Title Page From #+TITLE, etc keywords

texts:
I stumbled upon this archived email: https://lists.gnu.org/archive/html/emacs-orgmode/2011-02/msg01281.html and a suggestion is to create a custom title page that picks up the title, author, and date from the org file. There is a code block in the post that contains the syntax:
 address@hidden
   \newpage
   \null
   \begin{center}%
   \let \footnote \thanks
     {\usebox{\FIRM}}%
     \vskip 3em%
     {\LARGE address@hidden \par}%
     \vskip 1.5em%
     {\large
       \lineskip .5em%
       \begin{tabular}[t]{c}%
        address@hidden
       \end{tabular}\par}%
     \vskip 1em%
     {\large address@hidden
   \end{center}%
   \par
   \vskip 1.5em}

, but the post does not specify a way to add this to the org-latex-classes, on top of that, the post is really old and not up to date with the org-version I use (9.1.9). There are several posts in here that ask how to add custom classes to latex but I'm trying to do both add a custom title page that reads from the org metadata latex headers. Given that I have this written in my init.el:
;; Org Mode Custom Classes for Latex

(with-eval-after-load 'ox-latex
  (add-to-list 'org-latex-classes
               '("article"
                 "\\documentclass{article}"
                  " address@hidden
                     \newpage
                     \null
                     \begin{center}%
                     \let \footnote \thanks
                       {\usebox{\FIRM}}%
                        \vskip 3em%
                        {\LARGE address@hidden \par}%
                        \vskip 1.5em%
                        {\large
                         \lineskip .5em%
                           \begin{tabular}[t]{c}%
                             address@hidden
                              \end{tabular}\par}%
                            \vskip 1em%
                          {\large address@hidden
                           \end{center}%
                            \par
                             \vskip 1.5em}"
                 ("\\chapter{%s}" . "\\chapter*{%s}")
                 ("\\section{%s}" . "\\section*{%s}")
                 ("\\subsection{%s}" . "\\subsection*{%s}")
                 ("\\subsubsection{%s}" . "\\subsubsection*{%s}"))))

and that I am new to org-mode. How can I accomplish this by editing an existing org file that contains this:
#+TITLE: testing out org mode export latex
#+AUTHOR: me
#+EMAIL: me@meme.com
#+LANGUAGE: es
#+LATEX_CLASS: article
#+LATEX_CLASS_OPTIONS: [12pt,titlepage]
#+LATEX_HEADER: \usepackage{baskervald}
#+LATEX_HEADER: \usepackage[T1]{fontenc}
#+LATEX_HEADER: \usepackage{setspace}
#+LATEX_HEADER: \usepackage[AUTO]{babel}
#+LATEX_HEADER: \usepackage[hyperref,x11names]{xcolor}
#+LATEX_HEADER: \usepackage[colorlinks=true,linkcolor=SteelBlue4,urlcolor=Firebrick4]{hyperref}
#+EXPORT_FILE_NAME: export_with_custom_title
#+OPTIONS: f:t toc:nil |:t
#+STARTUP: showall

#+BEGIN_ABSTRACT
lorem ipsum lorem ipsum ....
#+END_ABSTRACT
#+BEGIN_LATEX latex
\thispagestyle{empty}
\newpage
\doublespacing
#+END_LATEX
#+TOC: headlines 2
#+BEGIN_LATEX latex
\singlespacing
\thispagestyle{empty}
\newpage
\setcounter{page}{1}
#+END_LATEX

* First heading
** second
*** and so on
paragraphs

So, how do I add a custom page title that modifies my title but retains the structure I have in my current org file? So, I am thinking that what I am trying to do is modify the custom article class so that it modifies only the title section by using #+TITLE:..., #+EMAIL:.. and #+AUTHOR:.. but keeps the rest of the edits.


texts: EmacsLisp : Can the pixel width of text in a proportional font be measured?

texts:
Given a face using a proportional font, can an accurate pixel width of a single row of text be measured in Emacs?

Note: not monospaced text.


texts: Help me avoid "|| true" in org babel bash statements

texts:
I'm writing a lot of manuals on how to accomplish things
in bash. Often I'm showing people something that doesn't work, and then go on to show what works.
When I'm showing something that doesn't work, the bash exit code is non-zero, and the result isn't captured by org.
So as a general rule I just add "|| true" to
most bash statements.
But this is a bit ugly, is there a better way? so that after
I do "org-publish" to html, my blog post is not littered with
"|| true"

# -*- org-export-babel-evaluate: nil -*-
#+PROPERTY: header-args:sh :prologue exec 2>&1 :epilogue :

#+BEGIN_SRC sh :exports both :dir /ssh:ubuntu@54.1.2.3:~/theSearch/
bundle exec rails server || true
#+END_SRC

#+RESULTS:
: sh: 2: bundle: not found

  Somewhat related http://kitchingroup.cheme.cmu.edu/blog/2015/01/04/Redirecting-stderr-in-org-mode-shell-blocks/


texts: How to check if a region is selected by mouse?

texts:
Usually a mouse selected region is highlighted and a region set by (set-mark-command) is not highlighted. But I don't know a programmatic way to check it.

Could anyone help?


texts: How can I switch to the most recent frame with other-frame?

texts: The function other-frame cycles through the open frames in a fixed order. This can be pretty inconvenient for example when the compiling log of LaTeX comes to the front, I want to switch back to my .tex document and I have plenty of other frame opened at the same time. On the major GUIs I know the window or application switching command switch between the most recent ones (and on can access the other ones by repeating the command).


texts:
I have just been using Hexl-mode to investigate some binary files.  What I would like though, is some way of highlighting the byte under consideration: at the moment the line and column indices are highlighted.  It would be very helpful if the intersection of that line and column could be highlighted with a color.  For example: the highlighted square in this picture have some color or background which distinguishes it from its surrounds:

Is there any way of doing this?

Note, I'm using:

GNU Emacs 24.3.1 (x86_64-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
 of 2014-03-08 on lamiak, modified by Debian

in Ubuntu 14.04 LTS


texts: How to control width of rectangular selection in Emacs 25?

texts:
There is a cool new feature in Emacs 25: visual support for rectangular
selection. However, I would like to set its width to one pixel when it's
“logical” width is zero columns of text. By default it's a bit too bold. Is
it possible?

Also, it would be cool if it didn't “shift” text on the right side of the
selection when its width is zero.


texts: Synchronize current dired path to next dired dir shown in a split window

texts:
first post :)

I wondered if anyone knew a way to quickly change the dired path of of the additional dired (in a split window) to the current dired path? like the traditional OFM synchronize panes?


texts: What is the proper way to add many items to a list?  I assume just using many add-to-lists is not the normal way?


texts: How to build Emacs for an embedded ARM Linux system

texts:
I am trying to build Emacs for an embedded ARM Linux system. Unfortunately, it is proving to be more difficult than I anticipated. I have the device mounted at /mnt/my_device. Now I am not sure exactly how to go about building Emacs from source.

I know I can set the prefix of the install via --prefix=/mnt/my_device/usr/local. However, beyond that, things get more difficult. How can I configure my Emacs build for my ARM system? After configuration, how do I compile Emacs? Using an ARM toolchain in QEMU or something? I know that there are cross-compiler tools that run on x86 systems, but should I use those given that configure may get the wrong info if I run it on my x86 system? Also, I need this installation of Emacs to be quite minimal, as this is an embedded system and there's not a lot of room.

Any tips that would help cohere and streamline this build process would be most appreciated.


texts: How can I get undo behavior in Evil similar to Vim's?

texts:
The default undo behavior in Evil is too coarse-grained because it considers anything taking place between entering insert mode and leaving it as one edit operation.  When you enter a whole paragraph of text during one insert and then execute undo, the whole paragraph is removed.  In contrast to that, Vim starts a new undo unit whenever you move the cursor in insert mode by means other than entering text.

Evil has a customization variable that can be used to get a more fine-grained undo history:

(setq evil-want-fine-undo t)

With this setting, Evil starts a new undo unit when the cursor is moved in insert mode, just like Vim does.  However, this setting also messes with how the replace operation is handled: if you replace a word using cw, you have to undo twice to restore the original word: once for removing the new word and once for reinserting the original word.  This is inconsistent with Vim and doesn't make much sense because replace should be atomic.

The question: How can I configure Evil and undo-tree in order to get Vim's undo behavior?


texts: Promoting and demoting headers in orgstruct mode

texts:
It looks as if the promotion and demotion of headers using M-Right, M-S-Right, M-Left, M-S-Left is disabled in orgstruct-mode as per this emacs-orgmode GNU thread.

Also, making direct function calls like M-xorgstruct-hijacker-org-metaright do nothing.

Does anyone have a patch that enables that?

Also, I can't have orgstruct-heading-prefix-regexp as nil; I need to set it at least to the comment characters of the major mode in which I am using orgstruct. And I am not planning on using block commenting for each orgstruct heading.

In my case I am setting this var to //;.

I am also curious... why would anyone not use the org mode directly if they are able to use orgstruct with this variable set to nil?


texts: Debugging a "binding stack not balanced" bug?

texts:
I'm trying to figure out how to approach a bug I've run into. I assume it's actually a bug in Emacs, but I don't know the right way to make headway with it. In short, I'm getting the message "binding stack not balanced (serious byte compiler bug)" when I try to send an HTTP message. I don't know how to tell if this is caused by something I've done, if it's a bug in Emacs, a bug in some other code, or what, so any help pointing me in the right direction would be great.

Here's some more context. I'm sending an HTTP message from Emacs to a Python web service. The payload/content-type is JSON. Emacs starts and manages the Python server, and certain configuration options determine whether that server is running under Python 2 or Python 3. This would normally not be relevant for Emacs, but strangely this defect only manifests itself when the server is running with Python 3. With Python 2 everything works perfectly.

I don't know if the Python2/3 difference is a complete red herring or not. It could be that some difference in the details of the network traffic between Python 2 and 3 is causing this defect. Or it could be that the values of the elisp variables which control the Python version are to blame. Of those options the first seems more plausible, but both seem pretty far-fetched. In other words, I'm stumped.

If it will help, I can post the stacktrace showing where the error is generated.

ED: The stacktrace can be seen here.


texts: Emacs/LaTeX displays _char as a subscript in the editor

texts:
Emacs seems to be doing some WYSIWYG with _, as if it were in math mode (in the picture, _ is followed by subscript 'o', inside the include statement. It shouldn't. I'm using Emacs/Tex out of the box, no special configuration.

GNU Emacs 24.5.1

$ pdflatex --version
pdfTeX 3.14159265-2.6-1.40.19 (TeX Live 2018)
kpathsea version 6.3.0

Minimal text example for reconstruction:

\documentclass{article}
\usepackage{pdfpages}
\begin{document}
  Underscore-o should not be set as subscript in the next line:
  \includepdf[pages={1}]{home/er/Documents/records/law/fr/om-ren/20170117_o}

  But it should be set as subscript in math environments like $A_o$.
\end{document}


texts: Org-mode default mouse-3 behavior overrides keybinding I've defined each time I revert a buffer

texts:
I've bound the mouse-3 to a custom function, with a statement

(define-key org-mode-map [mouse-3] 'foobar)

But when I revert some .org file, the keybinding of the mouse-3 goes back to the default and it displays the context menu.

I have this problem every time I start up emacs too. The init file loads, but the mouse-3 won't run the custom function I assigned for the org-mode in org-mode buffers. And when I eval-buffer the init file, it gets fixed until I revert those buffers.


texts: Does declare-function recognize functions declared via cl-defun?

texts:
It seems that declare-function + check-declare-file do not recognize functions defined via cl-defun.
I was happy using declare-function because it comes with check-declare-file that actually checks whether the declaration is consistent with the actual code in some other source file. However, when I upgraded the code for one of my declared functions, adding some keyword arguments and relying on cl-defun for handling them, check-declare-file could not validate and said that the function was not to be found.
Is there a workaround I could use? Or maybe declare-function is obsolete and there is some newer method I should use instead?


texts: If evil-scroll-line-down is not given a count argument, the last count is used.  This is not the behaviour of vim, which scrolls one line if no count is specified. How can I get vim behaviour?


texts: Trying to rebind a comand in the init file but the command is void

texts:
I'm trying to rebind the window selection with this in the dotspacemacs/user-config :

(global-set-key (kbd "&") ’select-window-0)

But at startup I got this error message :

  (Spacemacs) Error in dotspacemacs/user-config: Symbol's value as
  variable is void: ’select-window-0

And & is still unset.


texts: Idiomatic handling of region boundaries while modifying its content

texts:
I want to write a function to indent SQL embedded in a markdown file.

It seems to make sense to use the region for this.

However, the looping form I am using is:

(defun rr/sql-indent-region (beginning end)
  (interactive "r")
  (while (< (point) end)
     ...
     (forward-word 1)

The ... is adding \n characters after SELECT, FROM, GROUP BY etc, so that the block I started with no longer ends at END.

As I write this, I guess one option would be to copy the region to a temporary buffer, and use (< (point) (point-max)).  Is that the best way to proceed?


texts: Embed a youtube video in org-mode buffer

texts: I would like to display a youtube (or locally hosted) video inside an org-mode buffer, similar to how org-toggle-inline-images will preview an image file.  How can I do this?


texts: CSS mode won't indent values across multiple lines

texts:
When a line in my CSS file appears to be too long (typically a property followed by a bunch of values), I want to split them in to several new lines like this:

But I have to manually enter spaces before the lines to achieve that. In reality, when I hit TAB with my cursor on the url line, what I get is this:

The worst thing is that, after manually inserting the spaces, when I hit TAB again on the same line, it goes back to the ugly format.

This is not a significant issue but it really pains me and I really hope we can have a decent solution here. Thanks in advance!

M-x version:

GNU Emacs 25.1.1 (x86_64-apple-darwin16.1.0, NS appkit-1504.60 Version 10.12.1 (Build 16B2555)) of 2016-11-27


texts: Can I print output to stderr in batch mode WITHOUT a trailing newline?

texts:
In emacs --batch  (also, emacs --script),

(message "My Message")

will print "My Message" to standard error (file descriptor 2) along with a trailing newline.

What if I don't want the newline?  I see that theoretically,

(princ "My Message" standard-error)`

would work, if standard-error were defined.

Confusingly, standard-output and standard-input are defined, however.

Is this even possible?


texts:
In my init.el I have the below setting for the initial frame position:

(setq default-frame-alist
    '((top . 80) (left . 300) (width . 85) (height . 45)))

When I open a file in a new frame, it overlaps the previous frame.

How do I set the position of the new frame to be, for example, x width and y height from the previous frame?

This is so that the new frame will not overlap with the previous frame and all open frames (windows) will be clearly visible.


texts: Setup find-file-at-point to treat tilde as project root

texts:
A JavaScript project is setup with webpack path resolver like this:

    resolve: {
        alias: {
            '~': path.resolve(cwd, 'src')
        }
    },

This has the effect that a line in c:/projects/myproject/src/models/User.js

import '~/config/global';

will point to c:/projects/myproject/src/config/global.js.

Can I setup find-file-at-point (or any other interactive function) so that when in User.js the point is at the file path ~/config/global.js and I invoke f-f-a-p (or other magic), the global.js file is opened?

I.e., can I replace the meaning of ~ on a per-project or global basis?

This is Windows 10 if it makes a difference.


texts:
I have emacs version 23.3.1, the default color has dark purple text against a grey background which hurts my eyes.
I have read documentation* to try and look through the list of default preloaded emacs themes and pick a new color theme.
*where can I find emacs documentation specific to an older version?
I have tried M-x and the following commands, however all of them return with "[No Match]"

M-x color-theme-select
M-x customize-themes

When I try "customize-themes" on my local terminal I can see a list of themes and can pick between them (v24.5.1).
Is there anyway to achieve this on the older version of emacs?


texts: Org-mode: Is there a variable for a tags list like org-done-keywords is there for done todo keywords?

texts:
org-tag-alist will list tags exactly as they are defined in the .emacs or init file, e.g.

((:startgroup . nil) ("@computer" . ?c) ("@phone" . ?p) ("@home" . ?h) (:endgroup . nil))

Is there a variable that "cleans" this format so that the tags are easily accessible as a list?

("@computer" "@phone" "@home")

This is similar to how org-done-keywords will parse (though it'll only take the done keywords) the much messier org-todo-keywords (which is a list of sequences).


texts: context-aware inserting closing parentheses character

texts:
Most of auto pair packages provides that automatic insertion of closing parentheses (one of ), }, ].) if you type a opening parenthese.

However, what I want is when I type a closing pair, I want Emacs want to replace the closing character based on the context.  For example (| is the point):

([([|

No matter which closing character (like one of ), ], or }) I typed, I want Emacs smartly insert ], ), ], and ) respectively.

Is there any minor mode to do that?
(FYI, I need such a feature while I'm editing Scheme or Clojure source files)

Thanks.

After experimenting syntactic-close (provided by Manuel Uberti), I wanted to bind it to all of ), ], }, and >.

One minor update. It looks like that syntactic-close will not insert closing character if there is no matching opening one. And the set of closing characters varies depending on the major-mode. What I want it is to insert matching closing character if it found, and if not, I want it to insert the character that I typed.  So I came up with the small wrapper like this:

(defun syntactic-close-or-self-insert (&optional arg)
  (interactive "P")
  (unless (call-interactively 'syntactic-close)
    (call-interactively 'self-insert-command nil
                        [(listify-key-sequence (this-command-keys))])))

(let ((mode-maps (list
                  lisp-mode-shared-map
                  racket-mode
                  geiser-repl-mode-map
                  clojure-mode-map)))
  (dolist (map mode-maps)
    (define-key map [(?\))] 'syntactic-close-or-self-insert)
    (define-key map [(?\])] 'syntactic-close-or-self-insert)
    (define-key map [(?\})] 'syntactic-close-or-self-insert)
    (define-key map [(?\>)] 'syntactic-close-or-self-insert)))

It may not be optimal, but it does serve my purpose.   Thanks Manuel, and if you have any more advice, I'll appreciate it.


texts:
Question:
I'm running auctex and pdf-tools to view pdf's within emacs. My problem is that I'd like to scale the pdf window horizontally after running C-c C-c.
So far, I've created a hook to execute the settings I want in the buffer.
(add-hook 'pdf-view-mode-hook
        (lambda ()
      ;; key-bindings
        (my/pdf-view-keys)
      ;; dark mode
        (setq pdf-view-midnight-colors '("#f6f3e8" . "#242424"))
        (pdf-view-midnight-minor-mode)
      ;; open pdfs scaled to fit page
        (setq-default pdf-view-display-size 'fit-page)
      ;; more fine-grained zooming
        (setq pdf-view-resize-factor 1.1)
      ;; disable line-numbering
        (display-line-numbers-mode 0)
      ;; resize horizontally
        (setq right-margin-width 0)
        (setq left-margin-width 0)
        (setq fit-window-to-buffer-horizontally 0)
        (fit-window-to-buffer)
        ))

Now, the issue is that the window does not scale correctly at first. If I run fit-window-to-buffer manually (a few times), it scales the window nicely, but I'd like to avoid having to manually do this every time.
I'm guessing that the problem is that it's trying to scale before the pdf has loaded? If so, is there a way to delay the call to fit the window? If not, what am I doing wrong?
Partial Solution:
It appears that the following partially works.
(defun test-after ()
  (fit-window-to-buffer)
  (fit-window-to-buffer)
  )

(add-hook 'pdf-view-after-change-page-hook
      'test-after)

The fit-window-to-buffer call has to be made several times, but it doesn't seem to completely fit correctly. After scrolling through to the next page, however, it calls it again and scales it to the right size.
Thanks to NickD for the suggestion.


texts:
I am trying to turn on linum-mode and fci-mode for C++ editing. Here is my configuration:

;; If non nil line numbers are turned on in all `prog-mode' and `text-mode'
;; derivatives. If set to `relative', also turns on relative line numbers.
;; (default nil)
dotspacemacs-line-numbers t

The following is included in dotspacemacs/user-init ():

;; Activate column indicator in prog-mode and text-mode, except for org-mode
(add-hook 'prog-mode-hook 'turn-on-fci-mode)
(add-hook 'text-mode-hook 'turn-on-fci-mode)
(add-hook 'org-mode-hook 'turn-off-fci-mode 'append)

which should work according to https://github.com/syl20bnr/spacemacs/issues/4741. However the linum and fci modes are turned on for lisp but not for C++ mode. Anyone knows why?

My emacs version:

$ emacs --version
GNU Emacs 25.1.91.1
Copyright (C) 2016 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of GNU Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.


texts: Open file in orgmode with external application. Check if file exists and create file from template if necessary

texts:
I want to create a file with org-open-at-point from a template if that file does not exist. If it exists, I want to open it in an external app.

In org-mode, file-links are created by [[file:path-to-file.ext]]. Enter or C-c C-o opens that file. This behavior is defined by org-file-apps depending on the file extension.
According to the docs, org-file-apps can take functions as argument:

Possible values for the command are:
 string        A command to be executed by a shell; %s will be replaced
               by the path to the file.
 function      A Lisp function, which will be called with two arguments:
               the file path and the original link string, without the
               "file:" prefix.

(add-to-list 'org-file-apps '("\\.svg\\'" . "inkscape %s"))
opens that file in inkscape.

I wrote a function to create the file beforhand if it does not exist:

    (defun inkscape-open (path &optional link)
      "Open the path in inkscape. Copy template if path does not exist."
      (unless (file-exists-p path)
          (shell-command (format "cp /home/jolla/Dropbox/org/sketches/default.svg %s" path)))
      (shell-command (format "inkscape %s" path))
      )

and set it for svg-files:

 (add-to-list 'org-file-apps '("\\.svg\\'" . inkscape-open))

1.) This does not work: emacs tells me that the file does not exist. If it exists, emacs opens the file.

2.) I would like to modify my function so that it only creates the file if a specific directory (like Dropbox/org/sketches) is in path. What would I have to do?

3.) How can I switch focus to inkscape after org-open-at-point?

PS: if I create a new link-parameter like [[svg:path-to-file.ext]] like this:

(org-link-set-parameters
 "svg"
 :follow (lambda (path)
           (let ((actions '(("find-file" . find-file)
                            ("edit in inkscape" . inkscape-open))))
         (funcall (cdr (assoc (completing-read "Action: " actions) actions)) path))))

I can chose inkscape-open and the function works as expected. This is also described here. However, I don't want to create a new link type because this would prevent org-mode from showing inline images.


texts: How to change the font-lock string definition?

texts:
I wrote a simple mode with the following font-lock definition, which defines just some keywords:

(defvar marpa-mode-font-lock
  `((,(regexp-opt '(":default" "action" "lexeme" "default" "latm" "separator") t)
     . 'font-lock-keyword-face)
    )
  "Highlighting for Marpa mode")

I use it in my mode function in this way:

(set (make-local-variable 'font-lock-defaults) '(marpa-mode-font-lock))

When I use the mode more than just the keywords are highlighted. Strings are also highlighted with some kind of C or Lisp default syntax.

How can I disable the default string syntax in order to replace it with my own definition?

In the language for which I wrote the mode, strings are not delimited by double quotes. Instead they are delimited by single quotes and may have a suffix attribute like this: 'create':i.


texts: Sometimes experiencing heavy load using elpy

texts:
I have a couple of times experienced an elpy (Emacs Python development environment) python process using a considerable amount of CPU resources, loading the computer to an extent that I had to kill the python process. This seems to happen if there temporarily is a syntax error in the Python file edited.

I see that the elpy Python process is also loading the computer during startup:

PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
5011 fnielsen  20   0 1926520 232172  68344 S  51.0  5.7   0:52.33 python

I believe my elpy setup is pretty vanilla just following https://github.com/jorgenschaefer/elpy/wiki/Installation

What could be wrong?


texts: Symbol's function definition is void: special-form-p

texts:
Hello I'm currently running emacs 24.3.1 on Ubuntu 14.04. I recently discovered that I cannot call special-form-p as apparently its definition is void.

Do I need to change emacs versions or is this function defined in some library?


texts: Horizontal Scroll Bar Mode with trackpad

texts:
How can I use my trackpad to scroll left and right, when in horizontal-scroll-bar-mode?

I am running GNU Emacs 25.3.3 (x86_64-apple-darwin13.4.0, Carbon Version 157 AppKit 1265.21) of 2017-09-28.

This is the MacPorts edition by Mitsuharu Yamamoto.

Thanks!

UPDATE:

Following the advice of @lawlist (below) I needed to first find out what actions my trackpad left/right swipe are currently bound to (if any). So I entered C-h k and then scrolled right with my track pad. Here is the message that came back:

<wheel-right> at that spot runs the command mac-mwheel-scroll (found
in global-map), which is an interactive compiled Lisp function in
‘term/mac-win.el’.

It is bound to <C-wheel-right>, <S-wheel-right>, <wheel-right>,
<C-wheel-left>, <S-wheel-left>, <wheel-left>, <C-wheel-down>,
<S-wheel-down>, <wheel-down>, <C-wheel-up>, <S-wheel-up>, <wheel-up>.

(mac-mwheel-scroll EVENT)

Scroll up or down according to the EVENT.
Mostly like ‘mwheel-scroll’, but try scrolling by pixel unit if
EVENT has no modifier keys, ‘mac-mouse-wheel-smooth-scroll’ is
non-nil, and the input device supports it.


texts: Has anyone combined org-sidebar with org-panes? (persistent location & automatically in buffers)

texts:
In my ideal world, every org file could automatically open with a small sidebar always showing where I am, similar to how Typora works, which allows you to select other locations to go to. I'm trying to understand if a package (or package fork) to do this exists. Or any other way to accomplish this goal?

org-panes has several useful qualities:

Showing you in "sidebars" where you are at all times in a the "main" org buffer.
Simply bringing you to a particular point in the main buffer when a "sidebar" headline is selected.
Automatically enabling and disabling "sidebars" as you enter and leave the main buffer (updating the "sidebars" as you switch between org files).

Unfortunately, there doesn't seem to be any way to really disable the extra "contents" buffer.

org-sidebar is much more configurable in useful ways (e.g. in selecting what is visible). However, it doesn't seem to do any of the above, and narrows to a particular headline instead of just moving to it.

Has anyone added org-panes style functionality to org-sidebar? (
Or in lieu of that, just remove the content buffer? (I've been surprised to see more generally, that it seems there is no standard way of creating sidebars in emacs that associate with files or filetypes. Perhaps I'm missing something?) Or is there another package that fulfills these criteria?


texts:
currently I'm trying to connect to my gmail.com account via gnus.

Following emacswiki.org: Gnus#Gmail Quickstart guide I get

nnimap (gmail) open error: 'NO (ALERT) Please log in via your web browser: https://support.google.com/mail/accounts/answer/78754 (Failure)'.  Continue? (y or n) n
Couldn't open server on gmail

Searching suggested page by google did not provide solution I could use.

Where did I went wrong?


texts: How can I query Emacs from a separate process?

texts:
I'm interested in tracking how I spend my time at work. I have been using ManicTime, and it does much of what I want.

However, I use Emacs as my primary editor, and ManicTime doesn't know how to get info from Emacs. In its generic querying way, it attempts to get the window title (frequently in apps, the open document is in the title). For some apps, there are even plugins for ManicTime that are smarter about the target app.

I attempted to add a hook when switching buffers that wrote the Emacs PID and buffer name to a file that a plugin could read, but this did not work out very well for me. (My elisp could very well be suspect, but from a design perspective, this seems like a less than elegant and efficient solution.)

Is there a way to query Emacs from another process? This would be the simplest way to add Emacs support to ManicTime, but I don't know how to do it. Is there a good way?


texts: Heredoc or equivalent multiline string syntax in Elisp?

texts: In common-lisp we have the library cl-heredoc, is there an equivalent in EmacsLisp?


texts: How to use defun to make new text file with some content - without calling org capture?

texts:
I use the following function to make a new text file that is named with date and time:

(defun myfun-create-file-by-date ()
  (interactive)
  (find-file (format-time-string "C:/journal/%Y-%m-%d--%H-%M-%S.txt")))
  (global-set-key "\C-cn" ' myfun-create-file-by-date)

How can I add to this code, so it produces a new file with some text added?

I would like a headline with a property drawer like this:

#+STARTUP: content

* my headline

I would like to do this without using the capture-functionality of org-mode, because the capture files so produced are not stored before I push C-c C-c, but then the capture file is closed. This is ok for short notes, but not for files I will work in for hours.


texts: Prevent fill-paragraph from wrapping past horizontal rules

texts:
Say I have the following document:

Sir Bedevere
------------
Well, now, uh, Lancelot, Galahad, and I, wait until nightfall, and then leap out of the rabbit, taking the French by surprise - not only by surprise, but totally unarmed!

If I execute M-x fill-paragraph, I get this result:

Sir Bedevere ------------ Well, now, uh, Lancelot, Galahad, and
I, wait until nightfall, and then leap out of the rabbit, taking
the French by surprise - not only by surprise, but totally
unarmed!

However, I would like it to produce this output:

Sir Bedevere
------------
Well, now, uh, Lancelot, Galahad, and I, wait until nightfall,
and then leap out of the rabbit, taking the French by surprise -
not only by surprise, but totally unarmed!

Is there a way to get fill-paragraph to not auto-fill past a horizontal rule like this? Ideally it would work with other rule-like lines (made up of asterisks, octothorpes, etc.).

Edit: Can this be made to work in comments too? In this case, the horizontal rule would appear after the comment symbol(s), like in these examples:

# -----

// **********

/*
 * ##############
 */


texts: literate programming: do folks revise tangle blocks or make copies

texts:
So I'm making a website using an org document and tangling.

I've created the basic structure of the site using

* file coolsite.org

#+BEGIN_SRC sh
rails new coolapp
#+END_SRC

This creates a app/views/layouts/appication.html.erb file,
with basics like a head tag, body tag, html tag, etc.
If I wanted to add for example a <meta name="keywords" content="HTML,CSS,XML,JavaScript"> tag, I would copy that code
in to an org src block, and add my new tag.

#+BEGIN_SRC html :tangle app/views/layouts/application.html.erb
<!DOCTYPE html>
<html>
  <head>
    <title>Abc</title>
    <meta name="keywords" content="HTML,CSS,XML,JavaScript">
    <%= csrf_meta_tags %>
  </head>
  <body>
    <%= render 'layouts/navigation' %>
    <%= yield %>
    <%= render 'layouts/footer' %>
  </body>
</html>
#+END_SRC

So from the examples I've seen on the web, with literate programming, org files are ordered like a diary. Things are usually added to the end of the org file.

So let's say 1 week after writing the above tangle block, I need to add another meta tag to the file, in this case an author meta tag: <meta name="author" content="John Doe">

Do I:
Go back and revise the old tangle block
or
create a new block with the revised code?

If I choose the latter, an interesting situation can arise in the long run where a single org file has multiple :tangle blocks that output to the
same file. After the tangling, which one is left? is it the src block that appeared later-most in the org file ....

Note: The site is "generated" by doing C-c C-v t (org-babel-tangle)


texts: How I can make persp-mode save my workspace on every change?

texts:
I'm using persp-mode to save my workspace/desktop/opened buffers on Emacs close and restore it on Emacs start (configured via doom-emacs. However, sometimes I can't properly shutdown Emacs (e.g. laptop's sleep failure, empty battery etc.), so I would like persp-mode to save the workspace on every buffer list change. I did not find an appropriate configuration option in the persp-mode.el, but it's probably hackable, but I have no clue where to start looking for the right hook.

So how can I save my desktop on every change?


texts:
Context
I'm a teacher and I often want to show “bad” programs; in this case infinite outputting programs.
But while I want to show the bad I dont want my laptop crashing in class (nowadays on zoom)
The Emacs-Comint context
Comint processes can have large/indefinite/infinite output.
The commit buffer inevitably gets messed up with this
It would be good to have a minor-mode/hook for/in comint that finitizes the output in some configurable fashion.
Lets say the minor-mode is comint-finitize-output (cfo) having eg the following customizations

cfo-max-lines default 30
cfo-max-chars default 1000

So if the comint process spews out more than 30 lines or 1000 chars (whichever comes earlier)

the display stops with a message (customizable)
the process is interrupted with a sigint also customizable

Yeah I know about comint-preoutput-filter-functions
Problem is that since the output coming down the comint pipe is indeterminate in length, on account of things like

Relative speeds of Emacs vs inferior process
OS load

putting the above logic simplistically in a
comint-preoutput-filter-function will not work
Ideally if emacs could detect the state of the comint process to

waiting (at prompt)
thinking (ie computing) which if long enough signifies an infinite loop
outputting which if long enough signifies infinite output.

Then it (emacs) could act accordingly.
But I strongly suspect that foolproof detecting this is tantamount to solving the halting problem!!  So an approximate solution is good enough!
OTOH this seems a sufficiently common facet of comint usage that I'm sure there are hacky solutions around eg that use timers to guess whether two separately received batches of text are actually from the same REPL call. Maybe something more sophisticated is possible... Dunno
Does anyone know have something like this?

Examples
Of course in the most general case this is an infinite output problem and not specific to emacs.
I just thought I'd collect a slew of specific samples — C, Python, Shell and Haskell — to indicate that the problem is ideally solved at the Emacs end.
And then the statistics for each.
In a sense it just shows how clumsy I am at C-c C-c
What it doesn't show is how much my old creaky laptop whirrs and grumbles at the large output!
At least inside emacs it would sure help if emacs could help automate so to say my C-c C-c
C
#include <stdio.h>
int main(void)
{
  int i;
  for (i=0;1; i++)
    printf("%d ", i);

}

Python
def nats():
    i = 0
    while True:
        yield i
        i += 1

for i in nats():
    print(i, end = " ")

Shell
i=0
while true; do
    printf "%d " $i
    i=`expr $i + 1`
done

Haskell (at ghci)
[1..]

My current speeds
Note

Bigger is worse; I would like to stop at (say) 1000 chars or 30 lines
The shell outside emacs is not really relevant; just here for completeness

C in emacs shell : 9,230
C in outside shell (gnome-shell) : 1,561,605 (and my machine starts whirring and grumbling!)
Python at outside shell : 360,000
Python in inferior python 12,770
Shell script at shell : 1,123
Shell script in emacs shell : 2,067
Haskell ghci : 10,042


texts: How do I paste code without auto indentation

texts:
I just setup the latest Spacemacs. I'm pasting python code from here https://raw.githubusercontent.com/jpmens/mosquitto-auth-plug/master/examples/http-auth-be.py into a new buffer.

When I do this it indents almost every single line relative to the last. I'm using spacemacs from iTerm2 on OSX. I'm using Evil mode. I've tried toggling the value electric-indent-mode but ti doesn't help. I've also tried the command :set paste, but it gives me the error State paste cannot be set as initial Evil state.

So firstly, how do I stop the auto indentation? Secondly, what does the error message mean about the initial Evil state and how do I correct it?


texts: unicode character sometimes renders, sometimes doesn't

texts:
I'm not sure this is specific to helm, but when in helm's helm-ucs (C-c h 8) (though this also happens with helm-unicode), I notice that some characters show the weird little box glyph as if the character can't be rendered, but then when I actually "select" them in helm, they do render. This seems very curious, and so I myself am curious as to what could be causing this.

In the following example, consider the character RIGHTWARDS ARROW WITH NOTCHED TAIL, though this happens with all of the other characters that show boxes.

Not selected:

Selected:


texts:
My fringe indicators have become extremely tiny. Left side is flycheck, right side is git-gutter-fringe. So different packages, both extremely tiny.

My font might look huge, but it's not; it's 12. Doesn't matter if I change my font, or font size (the fringe doesn't scale).

I've tried (fringe-mode 20) and (set-font-face 'fringe nil :height 100). Linum is fine.

My emacs config is pretty simple and it works fine on my Mac. Did a straight copy over to Windows 10.

This is official Emacs build for Windows 10 (installed via choco).


texts: Is there a way to change order of the key in a hashtable?

texts:
Say i have following keys in hashtable:

"first1"
"second2"
"third3"
"forth4"

Is there a way to put key "third3" at the top. So that when i run func hash-table-keys i get following list:

("third3" "first1" "second2" "forth4")

I tried running remhash followed by puthash. But the order stays the same.


texts: How to get the first N words of an org file's main body

texts:
Given an org-mode file like this

#+TITLE: My title
#+AUTHOR: Me Myself

First and so on words sixth this we don't want

How can I get the first N words of the main body?  So for N=5, I would like to get the string First and so on words.

If possible, links should only count with their desc.


texts: MU4E: Force myself to check mail once and only once?

texts:
Emacs workflow is smooth. Usually we want it smoother. But I would like to make it less smooth..

This might be a strange question. I use emacs and mu4e to deal with my mails. However, the workflow is so smooth that sometimes I found myself checking it impulsively without thinking..

I wonder if there's a way to tweak this workflow (by adding some elips code?) to restrict myself from checking it too often!

I'm pretty new to emacs, and would like to learn some practical elisp-codes. This could be my first one to start with. Any pointers to relevant tutorial / documentations are appreciated.


texts: What keys can I use to create/delete and select side windows?

texts:
I have a shell buffer that's a good candidate for a side window:
I also regularly use an org buffer, that's always good to have around.

https://www.gnu.org/software/emacs/draft/manual/html_node/elisp/Side-Windows.html

I can't figure the keyboard shortcuts to:

make a side window
remove the side window
focus in to the side window


texts: Where to define macros for org-mode latex preview

texts:
When taking notes in Latex in org-mode, I use custom macros defined this way:

#+LaTeX_HEADER:\newcommand{\C}{\mathbb{C}}

I've got quite a few of these macros, so I'd like to put them all in a separate file that I include with

#+INCLUDE: "~/MyLatexMacros.org"

This works well when exporting my org file to latex, but doesn't work with latex preview.

Where can I set some macros to be used by latex preview ?


texts: How do you view history of nodes visited when reading through documentation?

texts: Also, can you view any metadata stored which describes the manuals/top level nodes you have previously visited?


texts:
My abbreviations are not expanding when I type the abbreviations

I have the following in my ~/.emacs for initiating the abbrev mode

(setq-default abbrev-mode t)

(setq save-abbrevs t)

(setq abbrev-file-name "~/abbrev.el")

(if (file-readable-p abbrev-file-name)
  (read-abbrev-file abbrev-file-name))

(dolist (hook '(erc-mode-hook
                emacs-lisp-mode-hook
                text-mode-hook))
  (add-hook hook #'abbrev-mode))

I get the following message saying that the abbreviation file is loaded

Loading /Users/baburaj/abbrev.el (source)...done
For information about GNU Emacs and the GNU system, type C-h C-a.
Mark set
Automatic display of crossref information was turned on
Applying style hooks...
Loading /Users/baburaj/auto/junk.el (source)...done
Loading /Users/baburaj/.emacs.d/elpa/auctex-12.2.0/style/article.elc...do
Applying style hooks...done
Sorting environment...done
Removing duplicates...done
Mark set

I also get the following when I type M-x list-abbrev

(text-mode-abbrev-table)

";af"          1    "aerofoil"

However when I type ;af it does not expand to aerofoil

What is the error that I am making? How can I fix this?


texts: Determine whether a given keybinding is the default

texts:
I'm curious if there is a mechanism for determining whether a keybinding is a stock (default) keybinding within Emacs (or a particular package).  Whenever I mention a command to someone I generally need to check whether what I use is the default.  (It would be great to have a visual indication of the customization in the describe-key/describe-key-briefly output!)

Given the basic structure of keymaps I imagine that it isn't possible to judge the modification state from the keymaps themselves.  I think it would be necessary to attach advice to define-key prior to customizations and then simply track them.


texts: Web-Mode + Yasnippets + Autocomplete, error before create-php-snippet

texts:
I am trying to use auto-complete + php-auto-yasnippets with web-mode, but I can't get the snippets to work correctly.

If I start typing imp, I correctly get auto-completion to implode but if I press TAB then RET I get an error

  payas/ac-insert-func-and-create-snippet: Wrong number of arguments: #[(arg) "Æ ?]  [ac-menu string ac-prefix arg last-command cl-struct-popup-tags ac-expand-common popup-selected-item ac-next ac-previous ...] 5 ("d:/UnixLike/home/.emacs.d/elpa/auto-complete-20160107.8/auto-complete.elc" . 42072) "P"], 0

If I type imp, then press TAB to get autocompletion, and then use C-c C-y to call yes/create-php-snippet, it works, and after that I can use TAB + RET to get yasnippets... (but only for implode, if I type another PHP functions, I have to call C-c C-y before TAB + RET).

Here is a part of my .emacs.el:

(require 'auto-complete-config)

(add-to-list 'ac-dictionary-directories "~/.emacs.d/ac-dict")
(ac-config-default)

(require 'yasnippet)
(yas-global-mode 1)
(require 'php-auto-yasnippets)

(require 'emmet-mode)
(require 'ac-emmet)

(require 'web-mode)

(payas/ac-setup)

(setq web-mode-ac-sources-alist
  '(("php" . (ac-source-yasnippet ac-source-php-auto-yasnippets))
    ("html" . (ac-source-emmet-html-aliases ac-source-emmet-html-snippets))
    ("css" . (ac-source-css-property ac-source-emmet-css-snippets))))

(add-hook 'web-mode-before-auto-complete-hooks
          '(lambda ()
             (let ((web-mode-cur-language
                    (web-mode-language-at-pos)))
               (if (string= web-mode-cur-language "php")
                   (yas-activate-extra-mode 'php-mode)
                 (yas-deactivate-extra-mode 'php-mode))
               (if (string= web-mode-cur-language "css")
                   (setq emmet-use-css-transform t)
                 (setq emmet-use-css-transform nil)))))

(define-key web-mode-map (kbd "C-c C-y") 'yas/create-php-snippet)

Below are the payas/ac-insert-func-and-create-snippet and payas/ac-setup function from php-auto-yasnippets:

(defun payas/ac-insert-func-and-create-snippet ()
  "Insert the selected function name then create its auto-snippet."
  (ac-expand)
  (yas/create-php-snippet nil))

(defun payas/ac-setup ()
  "Add ac-source-php-auto-yasnippets to ac-sources."
  (interactive)

  (ac-define-source php-auto-yasnippets
    '((depends yasnippet)
      ;; TODO The php-mode dictionary contains a few things (keywords and
      ;; the like) that should not be included
      (candidates . (ac-mode-dictionary 'php-mode))
      (action . payas/ac-insert-func-and-create-snippet)

      ;; Since these trigger yasnippet, use the yasnippet face.
      (candidate-face . ac-yasnippet-candidate-face)
      (selection-face . ac-yasnippet-selection-face)

      ;; The 'p' suffix on auto-complete entries stands for 'PHP', and helps
      ;; distinguish them from regular yasnippet entries.
      (symbol . "p")))
  (add-to-list 'ac-sources 'ac-source-php-auto-yasnippets))


texts: run-python and interactively choose working directory

texts:
When starting an R process using ESS (M-x R) you are interactively asked for a working directory.

To replicate this behaviour for python I have been opening up some random file in the directory I want to start python and then calling run-python, which is not as convenient. My question is - is there a way to replicate the R behaviour? That is, call my-run-python (or whatever) which prompts for a directory and then starts python there?


texts:
Is there a way to map Shift-left or other arrow keys to custom functions in term-char-mode?

I tried, but without luck:

(define-key term-mode-map [s-left] 'sandric/term-switch-line-mode)

Entering Shift-left in my terminal gives [1;2D, so I also tried:

(define-key term-mode-map "[1;2D" 'sandric/term-switch-line-mode)

But that also does nothing.


texts: Prevent DOS prompt when using emacs as an 'alternate editor'

texts:
I have activated in Alpine email client the following setting in order to use Emacs as an editor when composing emails:

[X]  Enable Alternate Editor Implicitly
Editor                              = emacs.exe

When I start to compose a message, by putting the cursor below the following area in Alpine

----- Message Text -----

Emacs will be started. But a DOS prompt (with the title C:\Program Files\GNU Emacs 24.4\bin\emacs.exe) is also opened at the same time.

My question is how to prevent this prompt from being opened.


texts: Can I configure eww to use pdf-view-mode (from pdf-tools) for PDFs instead of DocView?

texts: I use pdf-tools to read PDFs inside of Emacs and greatly prefer it to DocView. I just noticed that when I try to open a URL thar points to a PDF in eww, it uses DocView instead of the pdf-view-mode from pdf-tools. This is particularly annoying since DocView fails to display the PDF! Switching the buffer to pdf-view-mode manually then succesfully shows it. Can I configure things so that eww uses pdf-view-mode on the first try?


texts:
I'm trying to make a .wav file generator in Emacs Lisp. I have some binary data, as a sequence of bytes:
(setq binary-data (list 62 236 60))

I would like to insert that data into a file. I expect that file to be three bytes long.
If I try to insert it into a buffer, then write that buffer to a file, I get a file that consists of four bytes:
(with-temp-buffer
  (seq-doseq (char binary-data)
    (insert char))
  (write-region nil nil "~/char-inserted.wav"))

$ hd ~/char-inserted.wav
00000000  3e c3 ac 3c                                       |>..<|
00000004

So it seems like I'm having problems with inserting that single byte. I've also tried converting the data into a unibyte string, but that still gives me a four-byte file:
(with-temp-buffer
  (seq-doseq (char (apply #'unibyte-string binary-data))
    (insert char))
  (write-region nil nil "~/unibyte-string.wav"))

$ hd ~/unibyte-string.wav
00000000  3e c3 ac 3c                                       |>..<|
00000004

I've also converted the unibyte string to a multibyte string:
(with-temp-buffer
  (seq-doseq (char (string-as-multibyte (apply #'unibyte-string binary-data)))
    (insert char))
  (write-region nil nil "~/multibyte-string.wav"))

But this gives me an error:
> These default coding systems were tried to encode text
in the buffer ‘ *temp*-110101’:
  (utf-8-unix (2 . 4194284))
However, each of them encountered characters it couldn’t encode:
utf-8-unix cannot encode these:

It suggests I select one of the coding systems "raw-text" or "no-conversion", but I'm unsure how to do that, or if it will even help.
How do I save these three bytes into a file that ends up as a three-byte file? What's going on here?


texts:
I'd like to customize a bit mu4e in order to display nice utf-8 chars (or still better, colored emojis).

However, the problem is that the utf8 chars does not have the good width (even in the mono font), and may be bigger or smaller. So all the text after that char is shifted by a fraction of the normal width, which breaks the alignment. So I'm looking for a way to control spacing after displaying a big/small utf-8 char or picture. For example can I say something like:

"Display the utf-8 char ⚴ and leave space after until you arrive at the point that would be reached by replacing X by two characters with the default font width".
Or even better, would it be possible to say "Put the chars '⚓⚴❮' into at most 5 "normal" chars, fill with blank if needed, and then continue to write text as usual.
Or still better, "Put the chars '⚓⚴❮', fill with blank until you reach the next "block", and let me know how many spaces you used.

And if possible, I also want to do the same thing for images.

Thank you!


texts: How to automatically encrypt orgmode files?

texts:
I have a git repository where some org-mode files live. Some of them have a private nature and the server where the git repository lives can be accessed by some untrusted third party. Thatswhy I want to encrypt the private org files.

What I'd like to achieve is the following: In the beginning the file is encrypted. This can be either a symmetric key with a password or it can also be my GnuPG key. When I open the file, Emacs asks for the passphrase and opens the file (if pw entered correct). I can now work with the org file like with any other org file. When I save or close the file, it should be encrypted again. Also the git commit should be encrypted.

How can I do something like that with GNU/Emacs?


texts: Dynamic background colour for code blocks

texts:
Years ago I saw a feature in XCode where nested code blocks (delimited by {}) containing my cursor had graded background shades, with the lightest at my cursor, and the darkest at the outer level.

.e.g.

//Very Dark Grey bg
if(true){ // Dark Grey bg
    Velociraptor:
    for(i=0;i<foo;i++){ // Grey bg
        bar();
        while(true){// Light Grey bg
            do{// White bg
                // cursor here (ominous, isn't it)
                goto Velociraptor;
            }while()
        }
    }
}

And it would dynamically change to

// Dark Grey bg
if(true){ // Grey bg
    Velociraptor:
    for(i=0;i<foo;i++){ // Light Grey bg
        bar();
        // cursor here
        while(true){// White bg
            do{// White bg
                goto Velociraptor;
            }while()
        }
    }
}

Is there a package for this in Emacs / can it be done?


texts: M-x compile hangs with WARNING: terminal is not fully functional

texts: I have been using M-x compile for ages. Lately (our sysadmin has updated many things) it hangs after giving this message: WARNING: terminal is not fully functional -  (press RETURN).  Pressing return does nothing. I have tried changing the terminal to xterm, vt102, etc. with no change.  I get a similar warning with M-x shell but I can proceed after hitting return a few times.  Need to get this functionality back, thanks!


texts: Setting (setq system-time-locale "C") in daemon ineffective

texts:
I try to set the time locale to "C" in my config via (setq system-time-locale "C"). However, when using the emacs --daemon, it is not set properly and I end up with non-english date formats and weekday abbreviations when the system locale is different.
How can I set the time locale when using the daemon?


texts:
i have the problem, that lsp cant find my functions in python, because they are in a module, which is passed as parameter.
What is a another good way to find the use of a specific function?


texts: eval-when-compile: defsubst vs defmacro vs define-inline

texts:
I defined some simple functions in init.el, for example my-cache-file:
(defconst my-cache-directory
  (expand-file-name ".cache" user-emacs-directory)) ; ~/.emacs/.cache

(defun my-cache-file (x)
  (expand-file-name x my-cache-directory))          ; ~/.emacs/.cache/x

(setq savehist-file
      (my-cache-file "savehist"))

(setq backup-directory-alist
      `(("." . ,(my-cache-file "backups/"))))

This seemed like a good use-case for defsubst:
(defsubst my-cache-file (x) ...)

Then I started learning about compilation, and wanted to further optimize. I naively tried:
(defsubst my-cache-file (x)
  (eval-when-compile (expand-file-name x my-cache-directory)))

but the compiler complained (rightly) about the free variable x, so instead I wrapped the calling code:
(setq savehist-file
      (eval-when-compile (my-cache-file "savehist")))

(setq backup-directory-alist
      `(("." . ,((eval-when-compile (my-cache-file "backups/"))))

That last caller should probably be evaluating the whole alist at compile time, though, so I pulled the eval-when-compile up:
(setq backup-directory-alist
      (eval-when-compile `(("." . ,(my-cache-file "backups/")))))

I'd like to avoid littering my code with more eval-when-compile calls than necessary, and I wonder if there's a better approach I could take using macros or define-inline. The documentation makes define-inline sound promising:

Functions defined via define-inline have several advantages with respect to macros defined by defsubst or defmacro:

They can be passed to mapcar (see Mapping Functions).
They are more efficient.
They can be used as place forms to store values (see Generalized Variables).
They behave in a more predictable way than cl-defsubst (see Argument Lists in Common Lisp Extensions for GNU Emacs Lisp).

But the syntax looks cumbersome, and I can't find a single example of it being used in the wild. Nor can I find any explanation of it's claim that defsubst is less efficient.
Has anyone used define-inline, or is there a different macro I should look into, or should I just stick with defsubst?


texts: gnud-dired-attach  based keybinding does not work

texts: I am on gnu emacs 26.3 linux mint 20.1 and since my last OS update I cannot attach multiple files via dired using the key-binding C-c RET C-a. The message buffer indicates that C-c <return> C-a is undefined. Strangely, the supposedly equivalent C-c C-m C-a does work. Is there any way to debug what is happening? To be clear, I have a message and dired buffers open, I mark some files on dired, and hit C-c RET C-a, but the files do not get attached to the message buffer.


texts: How can I turn off flycheck minor mode for given directory

texts:
So my question is like in title. I want to turn off flycheck minor mode for all files in directory.
I have specified in my .emacs file that it should be on in c++-mode, c-mode and few others, but I don't want this rule to apply to one given directory.
 Preferably I'd like to turn it off using .dir-locals.el file.
My knowledge of lisp code is very limited and since specyfying
 (remove-hook 'c++-mode-hook 'flycheck-mode) hasn't done anything, I don't really know what should I do to get the effect I want.


texts: Why is my output of this org doc with lilypond code different than shown?

texts:
This page about ob-lilypond has an example of PDF output of this org file. The PDF looks great--small sheet music snippets under explanatory text. The whole thing fits on 2 pages. However, when I grab this org file and C-c C-e l o on my own system, the output PDF is 15 pages. Each paragraph of text and each small musical illustration are on their own page, over many inches of whitespace.

I don't know if this is significant, but I'll mention too that my system asks for a y/n input from me regarding the export of each individual block of Lilypond code during export.

The org-exporter had some complaints:

Overfull \vbox (75.24173pt too high) has occurred while \output is active
[2 <./ionian-eps-converted-to.pdf>]
<dorian-eps-converted-to.pdf, id=29, 541.02126pt x 814.04124pt>
<use dorian-eps-converted-to.pdf> [3]
Overfull \vbox (36.67224pt too high) has occurred while \output is active
[4 <./dorian-eps-converted-to.pdf>]

And I wonder if this has something to do with Lilypond being determined to print its version number at the bottom of each block?

And here's the beginning of the exporter's TeX file:

\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fixltx2e}
\usepackage{graphicx}
\usepackage{grffile}
\usepackage{longtable}
\usepackage{wrapfig}
\usepackage{rotating}
\usepackage[normalem]{ulem}
\usepackage{amsmath}
\usepackage{textcomp}
\usepackage{amssymb}
\usepackage{capt-of}
\usepackage{hyperref}
\usepackage[cm]{fullpage}
\author{Steven Arntson}
\date{}
\title{Modes in the Key of C}
\hypersetup{
 pdfauthor={Steven Arntson},
 pdftitle={Modes in the Key of C},
 pdfkeywords={},
 pdfsubject={},
 pdfcreator={Emacs 24.5.1 (Org mode 8.3.1)},
 pdflang={English}}
\begin{document}

\maketitle
\section*{Ionian Mode}
\label{sec:orgheadline1}
Lorem ipsum dolor sit amet, consectetur adipiscing elit...
\linebreak
\includegraphics[width=.9\linewidth]{ionian.eps}

\section*{Dorian Mode}
\label{sec:orgheadline2}
Lorem ipsum dolor sit amet, consectetur adipiscing elit ...
\linebreak

What might cause this?


texts: Access original keybinding for a mode after re-definition

texts:
I'm running into an odd case for rebinding keys, and I'm not sure of the solution. Basically, I want to replace a bunch of keybindings and move the original definition for each to a different key. Here's what I have so far:

(mapc (lambda (map)
          (define-key map "K" (lookup-key map "k"))
          (define-key map "k" #'<my new command for "k">)
        (list <a bunch of mode maps>))

The bad part is lookup-key: it will work fine on the first evaluation, but if I re-evaluate it will rebind "K" to my new binding for "k". So, my question is, is there a way to look up the original binding for a keymap? (Basically, I think I'm looking for the equivalent of noremap in vim.)


texts:
In git bash I can use git mv home/subdir_1/my_submod home/subdir_2/my_submod to move a submodule between directories. Git handles changing .gitmodules and stages the change to be committed.
Is there a way to do this cleanly with magit? I've tried using R in dired and then staging things in magit but magit runs into an error where it's looking for the original directory and can't find it since its been renamed.
I've checked the submodule transient docs but I don't see anything related to moving the submodule.
thanks for all suggestions/solutions.


texts: Why can't I bind to "M-s" prefix in global-map?

texts:
Running the following code:

(global-set-key (kbd "M-s s") 'forward-char)

Then using the command M-s s outputs

M-s s is undefined.

I have to bind to override-global-map for it to work:

(define-key override-global-map (kbd "M-s s") 'forward-char)

Why? Emacs version 25.1.1.


texts: How to fix latin character (e.g. ç, é) incorrectly displayed in emacs ess-buffer?

texts: When I read a file into R, and the file contain characters like  "ç" or "é" (latin characters) in a string, the ess-buffer shows meaninless (to me) numbers. For example, the string "ações" is displayed "a\307\325es". Do you know how to fix it?


texts: Insert left and right double quotation marks instead of ordinary quotation mark

texts:
For a given document (buffer), I would like use left double quotation mark “ (U+201C) and right double quotation mark ” (U+201D) instead of the ordinary double quote " (U+0022). I want to surround strings and sentences with these, and I want to do it as effortless as possible.

I post my first attempt as an answer below, since it works somehow..

Is this a recommended approach? I am looking for feedback and alternatives.


texts: How do I get company mode to recognize clang?

texts:
My current setup is as follows

Elementary OS Freya

Emacs version 24.5.1
company-mode 0.8.12
clang-3.5-dev
libclang-3.5-dev

I've checked that both libclang-3.5-dev and clang-3.5-dev are installed
and I have also checked that clang was in /usr/bin. There is no problem on init but when I open a cpp file the following error in thrown

Company back-end 'company-clang' could not be initialized:
Company found no clang executable

I'm trying to setup a C/C++ development environment in emacs, I was following this guide in order to achieve this.

i.e adding the following to my .emacs file

(require 'company)
(add-hook 'after-init-hook 'global-company-mode)
(setq company-backends (delete 'company-semantic company-backends))
(define-key c-mode-map  [(tab)] 'company-complete)
(define-key c++-mode-map  [(tab)] 'company-complete)

So how do I get clang recognized by company-clang?


texts:
Given I have a string that maybe came from a buffer, or a clipboard, or wherever; how do I sort-lines in it? Given that sort-lines only works with a region, I assume I have to put it to a temporary buffer, but I'm not aware of a common way of dealing with such tasks.

Googling the topic doesn't give anything relevant.


texts: Org-Mode Agenda Open in Left Window by Default

texts:
With a vertical split (C-x 3), regardless of which buffer I am in, C-c a opens the agenda on the right window, pushing my org file into the left window.

Is it possible to have the agenda open into the left window, rather than the right? If yes, how?


texts: Why is the . needed for adding suffixes to the 'auto-mode-alist?

texts:
In
https://www.emacswiki.org/emacs/AutoModeAlist
one needs to use this command in order to add .py for python-mode (add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode))
Why do we need the . between '"\\.py\\'" and the python-mode ?Thanks.


texts: emacs regex to match balanced parenthesis

texts:
How can emacs lisp match balanced parenthesis? for example: "foo(bar(),hee()) out()" should be match "foo(bar(),hee())".

I try below statement but it doesn't work:

#!/usr/bin/env emacs --script

(setq str "foo(bar(),hee()) out()")
(when (string-match "foo(.*?)" str)
  (print (match-string 0 str))
)

Currently, the output is:

"foo(bar()"

But my expected output is:

foo(bar(),hee())


texts: How to get proper hostname instead of NETBIOS name

texts:
I'm using emacs 25.2.1 on Windows with spacemacs (0.200.9). I also start emacs as a service using emacsclientw.exe --daemon. I'm attempting to get the current host name using (system-name) as follows:

(defconst jp-hostname
  (car (split-string (system-name) "\\." t)))

Unfortunately, when I do this, the jp-hostname variable contains the NETBIOS name instead of the hostname. For example, my laptop's name is "jaundiced-outlook", but jp-hostname is set to "JAUNDICED-OUTLO".

Calling (system-name) after emacs is up and running returns what I would expect: "jaundiced-outlook".

By waiting until emacs is finished loading and executing the above code using eval-region, jp-hostname gets set correctly to "jaundiced-outlook".

Is there a reason for this behavior? Is there a way to get around this kind of thing?


texts: Skip noweb reference at export when org-export-babel-evaluate is set to nil

texts:
I have an org-mode document with many code blocks that I do not want to be evaluated at each export so I set the org-export-babel-evaluate to nil to avoid these evaluations which works as expected.
However, I also have in some of these code blocks a noweb reference but I want it to be hidden at export. I use the header option noweb : strip-export and it works as expected if org-export-babel-evaluate is set to t but stops working if org-export-babel-evaluate is set to nil (In this case the noweb reference is not expanded but is present in the exported document).
Example of code block:
#+BEGIN_SRC python  :results output :exports both  :noweb strip-export
<<no_web_block_to_be_hidden_at_export>>
...
Code Block Instructions
...
#+END_SRC

Is there a way to change this behavior ?


texts: Retrieve all the major modes equipped with emacs

texts:
I learned that GNU Emacs Manual

  Most major modes fall into three major groups. The first group
  contains modes for normal text, either plain or with mark-up. It
  includes Text mode, HTML mode, SGML mode, TeX mode and Outline mode.
  The second group contains modes for specific programming languages.
  These include Lisp mode (which has several variants), C mode, Fortran
  mode, and others. The third group consists of major modes that are not
  associated directly with files; they are used in buffers created for
  specific purposes by Emacs. Examples include Dired mode for buffers
  made by Dired (see Dired), Message mode for buffers made by C-x m (see
  Sending Mail), and Shell mode for buffers used to communicate with an
  inferior shell process (see Interactive Shell).

Most major modes fall into three major groups of Text, Programming and File.

How could I retrieve a list of all the major modes equipped with my emacs.


texts: How to keep grep results in eshell buffer

texts: When entering the grep command in an eshell in spacemacs, a separate window and buffer are created to list the grep output results. However, I would prefer for the output to be listed in the eshell buffer like how a stand-alone terminal application would normally behave. How can this be achieved?


texts:
Is there anywhere I can download a pre-compiled executable of the Emacs development version, all built and ready to run on Windows?

Doesn't have to be a daily build. Anything from the last month or so would be fine.


texts: How to properly display script shell command output

texts: I wish to be able to open current shell output in emacs, for that I use script command that logs all the output into file typescript. The problem is that it consist also with terminal codes for colors and other necessary stuff, which is not parsed by emacs. I found function display-ansi-colors and it displays part of term sequences correctly, but a lot of them still undecoded. I using "xterm-256color" terminal. Is there a way to decode all term sequences correctly in emacs buffer?


texts: How to prevent backup for files larger than 3MB?

texts:
One of the emacs's nice features is Backup.
But is there any way to prevent backup for files larger than 3MB?
Thanks!


texts: How do you make an optional field and comma in a yasnippet?

texts:
I want to make a snippet for a function with optional arguments.  For example something like:

myfunc($1, $2, $3)

But in this case, $2 may be optional. I know I can press Ctrl-D to skip it, but it leaves behind the comma. How do I get a snippet to delete the comma if I skip the field?


texts: Traversing the mark rings when combining global and local jumps in Emacs

texts:
I am wondering why it is so difficult to go back when you mix local and global jumps in Emacs. Maybe I am missing something. For example,
if I am in buffer 1 and jump to position 100 (for example using a search command or a bookmark jump), then jump to position 1000, then I jump to buffer 2 position 500 (using for example a bookmark jump).

If I now want to backtrace this history of jumps, I first need to know that
I should be using the global mark ring (not the local) to jump to buffer 1, then I will end up at position 100 in buffer 1 (not position 1000 as I wanted), so I need to access the local mark ring for buffer 1, to get to my desired position. This is far from ideal, I would like to avoid having to think about local vs global mark ring when I go back, and I would like to go back to the previous location, whether it is in the current buffer or in some other buffer.

By the way, I am using helm-all-mark-rings for this kind of movement.

The solution provided by backbutton involves "abusing" the global mark ring to also record local jumps. Is this safe to do, and will it work with helm-global-mark-ring? Are there built-in methods that I have missed?

See also kozikow/back.el


texts: Show line at opening brace when cursor is after the closing brace (Perl)

texts:
Something I like in Emacs is positioning the cursor after the closing brace/paren highlights the opening brace/paren.
Even better, like in Emacs-Lisp mode, the opening ( line is displayed in the minibuffer. This is convenient when that line is too high up and cannot be seen in the display.
In Perl and CPerl mode, however, the opening { line is not shown in the minibuffer. Is there a way to have it shown?
Edit Tried to rename my .emacs / .emacs.d (in case the long config wrote a long time ago would interfere), but that didn't improve anything in these Perl modes.
(using Emacs 26.3 GUI on Ubuntu 18.04 & 20.04)


texts: How to repeatedly move forwards or backwards by a screenful of text?

texts:
I tried C-u 1 C-v, which based on the documentation should repeat C-v one time.  Unfortunately, it only ends up scrolling a line instead of a screenful.

Any guidance appreciated.


texts: How can I remove the --shell option in the definition of flycheck-define-checker sh-shellcheck?

texts:
Obviously, I could go in and edit the appropriate line in flycheck.el, or copy the function to my init.et and modify it, but then I would be out of sync with any changes in updates to flycheck.

I'd rather write a small Lisp statement that just overrides the :command piece in my init.el. Is that possible?


texts:
I'm attempting to suppress certain minibuffer messages, but can't seem to get my configuration to work. There are two stack exchange answers that address this (here and here) and both suggest using a let-binding.

For instance, I've tried running emacs -Q and in the *scratch* buffer using this:

(let ((inhibit-message t))
  (message "End of buffer"))

Then, I evaluate the expression with C-x C-e and cursor down, but I still see End of buffer in the minibuffer. What seems even stranger to me is that running C-x C-e in the first place also caused the string to appear in the minibuffer even though inhibit-message is locally non-nil.

On a related note, I don't understand on a theoretical level how the let form would achieve the desired affect here. As I understand it, when the let expression is encountered inhibit-message is locally bound to t and then the message function is called with the string argument, which would have no effect on the minibuffer since inhibit-message is non-nil (which is apparently wrong because C-x C-e causes the message to appear). However, when this same message is called another time, I don't see why the message should be suppressed. This expression doesn't cause all calls to (message "End of buffer") to be evaluated within this let does it? If so, how does it? Am I missing the mechanism entirely?


texts: Call mode-specific backspace from "smart-backspace" function

texts:
I'm writing an IntelliJ-style "smart backspace" function which does the following:

If the whole of the line up to the point is whitespace

Join the line to the previous line, killing that whitespace
Indent the line

Otherwise, just delete a char as normal

I've got the smart backspace working, but the as normal part is proving difficult.

(defun smart-backspace ()
  (interactive)
  (if (beginning-of-line-text-p)
      (progn (join-line)
             (indent-according-to-mode))
      (delete-backward-char 1)))

The problem is most language modes provide their own version of delete-backward-char, so overriding backspace like this doesn't do handy (or crucial!) stuff such as paredit/smartparens' sp-backward-delete-char, which keeps the sexp tree intact when you backspace over a closing delimiter.

What I'm asking is: is there a way to call the "default" binding for a key or mode from inside a function such as mine?


texts: Mac OS X HHKB  not captured by GNU Emacs

texts:
I've been using GNU Emacs and Mac OS X (Early 2015, 10.13.2) and HHKB works well.

Several days before I bought a new Macbook Pro(2018, 10.14.1) and plugged the same HHKB. Everything works fine but the <C-left> (or Control + Fn + ;) and <C-right> not captured by Emacs.

I've tried that the <C-up/down/left/right> on the old Macbook and those keys can be captured by Emacs, but on the new Macbook, these keys are intercepted by OS and not captured by Emacs.

How can I fix this?


texts:
Here's my function:

(defun scroller-down ()
  "Scrolling down conditional for buffer and minibuffer."
  (interactive)
  (if (active-minibuffer-window)
      (ivy-scroll-down-command)
    (scroll-down-command)))

(defun scroller-up ()
  "Scrolling up conditional for buffer and minibuffer."
  (interactive)
  (if (active-minibuffer-window)
      (ivy-scroll-up-command)
    (scroll-up-command)))

This function determines if the minibuffer is open.

If it is open and the cursor is in it, it will scroll in the minibuffer.

However, if it is open and the cursor is not in it, it will neither scroll in the minibuffer, nor the current buffer that the cursor is in.

My goal is to determine which scroll to use depending on if the cursor is in the minibuffer or not.

Is there a variable that returns true if the cursor position is in the minibuffer?

Also is there a better way to condense this function into one, and use a cond to check if a certain key is pressed, thus activating the appropriate scroll function??


texts: when I edit javascript, I'm usually actually editing someone else's code. Is there a way to dynamically set the value of js-indent-level from a .eslintrc file?


texts: Make soft word wrap not cut words in the middle of the line?

texts:
Currently, in text files, Emacs is wrapping text (soft wrap), but if a word is at the end of the line, then it puts half of the word at the end of the line and the second half at the beginning of the next line.

Is there a way to make it not cut words across lines like this (i.e. put the whole word at the beginning of the next line)?


texts:
Windows 10 (64 bit), Emacs 25.1, Helm helm-20180212.2045

Run shell
In she run Android command adb logcat -vtime
Here result

Nice
M-x C-x b - show helm-mini buffer
Nice

Than select shell buffer
Again M-x C-x b - show helm-mini

But sometime (I don't know when) I input M-x C-x b and helm-mini buffer not show very long time. Show progress bar. Smt like "freeze" Emacs.
Why this hapend?


texts: Getting "Symbol's function definition is void: nil" when adding or following up in GNUS

texts:
Emacs 24.5 (from http://emacsformacosx.com), GNUS 5.13, OS X El Capitan.

When I try to post to a newsgroup or followup an existing post, I get the error "Symbol's function definition is void: nil" from GNUS.  Viewing works fine.

Any idea what could be causing this?


texts: Can I set MANPAGER to open a man page with emacs?

texts:
I am able to use man inside emacs. M-x man , <ln> , [enter].
=> From the shell can I open man pages from the shell? For examlpe doing $ man ln can open the man page inside the emacs?

$ export MANPAGER='emacsclient -t -q'
$ man ln
❯ # opens the `*scratch*` file


texts: How to remove the link from org-capture templates

texts:
I have the following org-mode capture template:

'(org-capture-templates (quote (("t" "Task" entry (file+headline "~/org/tasks.org" "Incoming") ""))))

The resulting capture buffer looks like this  (very vaguely, but you get the idea):

**
   [[link to headline at point]]

This is what I want, except for the link. How do I avoid getting that? I'm not finding anything in the documentation on template elements but I must be missing something?


texts:
While using emacs e-mails, receiving works fine. Sending does not. If I place my .authfile in the home folder sending mails works fine. It does not ask for smtp server or user or password.

If I move the file to a different folder and use
(setq auth-sources "/different_folder/.authinfo")
it asks me to provide the smpt server and all credentials.
It looks like the variable doesn't work.

Anyone some suggestions on this?

Thanks


texts: How to pass an argument from command to another command?

texts:
From the package Neotree, I want to bind a key, that moves to the upper directory.

The upper directory is always on the top with .. (up a dir). So I go to the first line of the neotree buffer, and call neotree-enter to move to the upper directory. As a true Emacs'er, I figured out I need to modify it to my own preference.

So I created a function:

(defun neotree-go-to-upper-directory ()
    (interactive)
    (evil-goto-first-line)
    (neotree-enter)
)

(evil-define-key 'normal neotree-mode-map (kbd "h")'neotree-go-to-upper-directory)

After pressing h in NeoTree buffer, the cursor moves only to the
top. But nothing happens. Then I call M-x neotree-enter, but still
nothing happens.

When trace back into the source code of neotree-enter with C-h f
then following the link, it's defined as:

(defun neotree-enter (&optional arg)
    "NeoTree typical open event.
    ARG are the same as `neo-open-file'."
    (interactive "P")
    (neo-buffer--execute arg 'neo-open-file 'neo-open-dir))

So I modified my function with adding the arguments as parameters:

(defun neotree-go-to-upper-directory (arg)
    (interactive "P")
    (evil-goto-first-line)
    (neo-open-dir arg)
)

Re-evaluated and calling neotree-go-to-upper-directory again inside Neotree
buffer, but still nothing happens. Something I went wrong. But can anyone tell
me where my code went wrong? It would be appreciated.

EDIT: For clarifity, as Lawlist suggested, I'm interested in a neotree
solution. But some knowledge of Elisp would be also nice, because I'm struggling
to understand why the function works for Neotree as well, and not in my case.

I got an working answer below:

(defun neotree-go-to-upper-directory ()
    "Go to the parent directory in the NeoTree buffer."
    (interactive)
    (neotree-dir ".."))

But unfortunately, this is not always working and I can't figure out what the cause of this is.  For example, I enter a directory with neotree-enter and I want to call the function, then nothing will happen. It will be only working if I call neotree-change-root-directory then calling the function afterwards, it seems. And not when I do neotree-enter


texts: Org export to odt incorrectly use "DEADLINE" for "SCHEDULED"

texts:
I noticed that when org-exporting to and odt file, the SCHEDULED timestamps are changed to DEADLINE instead.
A minimum working org file:
#+TITLE: Test file
#+OPTIONS: p:t

* Section 1
** TODO Section 1.1
SCHEDULED: <2020-11-28 Sat>

Dummy texts.
** TODO Section 1.2
DEADLINE: <2020-11-30 Mon> SCHEDULED: <2020-11-28 Sat>
Dummy texts.

Then I C-c C-e, select export to ODT. This is the resultant odt content:

Could this be a bug of org?
Versions:

OS: Manjaro Linux
Emacs: GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.22, cairo version 1.17.3) of 2020-08-29
Org: 20201123 from Archive org


texts: Compile emacs from feature/native-comp (gccemacs) branch on Ubuntu

texts:
I want to compile the gccemacs branch of Emacs.  When I run ./configure, the configure script errors with:
cd emacs
git checkout feature/native-comp
./autogen.sh
./configure --with-nativecomp

configure: error: Installed libgccjit has failed passing the smoke test.
You can verify it yourself compiling:
<https://gcc.gnu.org/onlinedocs/jit/intro/tutorial01.html>.
Please report the issue to your distribution.
Here instructions on how to compile and install libgccjit from source:
<https://gcc.gnu.org/wiki/JIT>.

Here's some version info:
$ cd emacs/
$ git log -1
  commit 2593bbee51f4d15d3a4fc1d4e2e3b215222f783a (HEAD -> feature/native-comp, origin/feature/native-comp)
  Author: Andrea Corallo <akrl@sdf.org>
  Date:   Sat Jul 4 15:53:15 2020 +0100

      * Relax constant folding rules

      * lisp/emacs-lisp/comp.el (comp-function-optimizable-p): No need to
      check for operands or result to be fixnums.

$ uname -r
5.4.0-7634-generic

$ gcc --version
gcc (Ubuntu 9.3.0-10ubuntu2) 9.3.0

I can verify that gccjit fails by compiling https://gcc.gnu.org/onlinedocs/jit/intro/tutorial01.html. It segfaults. Here's a gdb trace:
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7566d63 in ?? () from /lib/x86_64-linux-gnu/libgccjit.so.0
(gdb) where
#0  0x00007ffff7566d63 in ?? () from /lib/x86_64-linux-gnu/libgccjit.so.0
#1  0x00007ffff7566e85 in ?? () from /lib/x86_64-linux-gnu/libgccjit.so.0
#2  0x00007ffff678b2a1 in ?? () from /lib/x86_64-linux-gnu/libgccjit.so.0
#3  0x00007ffff678d8d1 in ?? () from /lib/x86_64-linux-gnu/libgccjit.so.0
#4  0x00007ffff678e9dd in ?? () from /lib/x86_64-linux-gnu/libgccjit.so.0
#5  0x00007ffff678ea68 in ?? () from /lib/x86_64-linux-gnu/libgccjit.so.0
#6  0x00007ffff678d32b in ?? () from /lib/x86_64-linux-gnu/libgccjit.so.0
#7  0x00007ffff6784851 in ?? () from /lib/x86_64-linux-gnu/libgccjit.so.0
#8  0x00007ffff67775b6 in gcc_jit_context_compile () from /lib/x86_64-linux-gnu/libgccjit.so.0
#9  0x00005555555555a5 in main (argc=1, argv=0x7fffffffda38) at hello.c:99
(gdb) list
62
63    gcc_jit_block *block = gcc_jit_function_new_block (func, NULL);
64
65    gcc_jit_block_add_eval (
66      block, NULL,
67      gcc_jit_context_new_call (ctxt,
68                                NULL,
69                                printf_func,
70                                2, args));
71    gcc_jit_block_end_with_void_return (block, NULL);

My suspicion is that I need a more recent version of GCC, since the Dockerfile for gccemacs installs gcc from source in the demo Dockerfile: https://gitlab.com/koral/emacs-nativecomp-dockerfile/-/blob/master/Dockerfile


texts: Quoting a replacement string for a regular expression

texts:
Emacs Lisp has regexp-quote to quote any string to match it literally.  Apparently, there is no equivalent function to quote an arbitrary replacement string to use it literally.  I mean, what could I use instead of the imaginary regexp-quote-replacement in the following contrived[1] code?

(replace-regexp (regexp-quote "^$") (regexp-quote-replacement "\\&\\?"))

This code would be meant to replace a literal ^$ with a literal \&\?.

--

[1] I know that I could use replace-string in this case to achieve the same result.


texts: How to list all the packages installed from source

texts:
Is there a way to list all the packages originally installed via package-install-file?

Looking at the results of package-list-packages, it doesn't differentiate between different installation methods.


texts: How do I persist M-x calls so they can be displayed in MRU order?

texts:
I would like it if my Emacs were to save the M-x calls in most-recently used order and if this order could persist and grow across restarts/other sessions. I am using Helm, so I guess I should be asking about helm-M-x, but I thought this would be a general problem which might have a solution.

Ideally the solution would not depend on desktop-save-mode, but if it does I am okay with that.

Edit:
Apparently I should be using savehist as I gathered from the comments, but for some reason it is not working. It seems like my savehist file is being populated, but it is not being loaded when I start Emacs anew.

(setq savehist-file "~/.emacs.d/savehist")
(setq history-length t)
(setq history-delete-duplicates t)
(setq savehist-additional-variables
                    '(savehist-minibuffer-history-variables
                      magit-read-rev-history
                      helm-M-x-input-history
                      read-expression-history
                      helm-grep-history
                      minibuffer-history
                      file-name-history
                      ido-file-history
                      evil-ex-history
                      mark-ring
                      search-ring
                      extended-command-history
                      evil-jumps-history
                      kill-ring
                      search-ring
                      regexp-search-ring
                      compile-history
                      log-edit-comment-ring
                      command-history))
(savehist-mode 1)


texts:
When I terminate a Multi I-search, Emacs takes me back to the original buffer rather than the result I'm looking at.

I've tried terminating the search with RET, escape, arrow keys, and none of these have worked. What should I be doing instead?

To reproduce:

Start Emacs with emacs -Q
Open several buffers.
M-x ibuffer
Mark several buffers with m
Start Multi I-search with M-s a C-s
Search for something and press C-s until you're in at least the second buffer.
RET returns you to the original buffer!


texts:
What does the -> mean here:
(interactive
  (list
    (-> (dap--completing-read "Select configuration template: "
          (-mapcat #'funcall dap-launch-configuration-providers)
          'cl-first nil t))))


texts: Is it possible to cancel a key combination half way through?

texts:
Being new to Emacs, it often happens to me that I press some key combination and then, seeing the preview with which-key of how the key combination should finish, realize that I made a mistake somewhere, and I want to use none of the combinations shown.

Is there a way to then cancel a partially completed key combination? I usually end up pressing ESC, in the hope that there is no combination that ends in ESC (which sometimes is not true). Is there a better way?


texts: In latex preview pane mode, make the pane stay where I put it

texts:
Does anyone know how to make the pane in latex preview pane mode stay put? When I move it to the frame/window I would like it to be, it pops back to its default window when I refresh it, M-p.

Edit: Precisely what I mean.

Install latex-preview-pane from melpa repo
Open any .tex file. C-x C-f "/mydir/myfile.tex"
Open a .pdf preview of the .tex file: M-x latex-preview-pane-mode. This will open a new myfile.pdf buffer in a new window to the right of myfile.tex
Close the preview window C-x 1
Open new frame C-x 5 2
Open the myfile.pdf buffer in the new frame using C-x b.
At this point I have a preview frame that I can place where ever I'd like, preferably on a second monitor
Return to the original window containing myfile.tex, C-x 5 o
Make changes to myfile.tex
Update the myfile.pdf buffer to reflect changes M-p.

At this point the frame that was created and moved is still in place and updated, but a new window opens to the right of the myfile.tex buffer again with another copy of the preview pane. So I now have two views of the myfile.pdf buffer.


texts:
Is there a way to format target links created by org-mode when using radio targets such as the following:

<<<some text>>> where that some text is linked back

When outputting to HTML or PDF (created through LaTeX processor), the links are active and work well when clicked. However, I want the second "some text" printed in a different format so visually it's apparent that is a hyperlink. By default radio source and targets print the same.


texts: AUCTeX preview breaks if monitor orientation isn't normal or inverted

texts:
When I use AUCTeX's preview feature on a monitor who's orientation is normal or inverted (i.e. rotated either 0 or 180 degrees) then everything works perfectly and the png files from the resulting _region_ folder look nice:

.

However, as soon as I try and generate the preview images on a monitor who's orientation is left or right (i.e. rotated either 90 or 270 degrees) then the png files from the resulting _region_ folder look all squashed:

.

If I use two monitors simultaneously then the results will depend upon which monitor the Emacs window is currently in; I find it surprising that the window position can even affect the result of such a feature. I have disabled all custom configuration on my Emacs, tried multiple desktop environments and even swapped monitor but the problem persists.
At what point could the orientation of my monitor affect AUCTeX's preview function and how I can fix the problem?